author | psandoz |
Fri, 08 Sep 2017 10:46:46 -0700 | |
changeset 48826 | c4d9d1b08e2e |
parent 47216 | 71c04702a3d5 |
child 59201 | b24f4caa1411 |
permissions | -rw-r--r-- |
8821
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
1 |
/* |
39483
3a7e016ba204
8160717: MethodHandles.loop() does not check for excessive signature
mhaupt
parents:
37781
diff
changeset
|
2 |
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. |
8821
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
4 |
* |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
10 |
* |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
15 |
* accompanied this code). |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
16 |
* |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
20 |
* |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
23 |
* questions. |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
24 |
*/ |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
25 |
|
8822
8145ab9f5f86
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
8821
diff
changeset
|
26 |
package java.lang.invoke; |
8821
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
27 |
|
33674
566777f73c32
8140606: Update library code to use internal Unsafe
chegar
parents:
33312
diff
changeset
|
28 |
import jdk.internal.misc.Unsafe; |
37593
824750ada3d6
8154231: Simplify access to System properties from JDK code
redestad
parents:
36934
diff
changeset
|
29 |
import sun.security.action.GetPropertyAction; |
9780
6fc3b49cfee4
7050328: (jsr-292) findConstructor throws ExceptionInInitializerError if run under SecurityManager
jrose
parents:
9731
diff
changeset
|
30 |
|
39483
3a7e016ba204
8160717: MethodHandles.loop() does not check for excessive signature
mhaupt
parents:
37781
diff
changeset
|
31 |
import java.util.Properties; |
3a7e016ba204
8160717: MethodHandles.loop() does not check for excessive signature
mhaupt
parents:
37781
diff
changeset
|
32 |
|
8821
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
33 |
/** |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
34 |
* This class consists exclusively of static names internal to the |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
35 |
* method handle implementation. |
8822
8145ab9f5f86
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
8821
diff
changeset
|
36 |
* Usage: {@code import static java.lang.invoke.MethodHandleStatics.*} |
8821
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
37 |
* @author John Rose, JSR 292 EG |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
38 |
*/ |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
39 |
/*non-public*/ class MethodHandleStatics { |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
40 |
|
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
41 |
private MethodHandleStatics() { } // do not instantiate |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
42 |
|
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10419
diff
changeset
|
43 |
static final Unsafe UNSAFE = Unsafe.getUnsafe(); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10419
diff
changeset
|
44 |
|
9780
6fc3b49cfee4
7050328: (jsr-292) findConstructor throws ExceptionInInitializerError if run under SecurityManager
jrose
parents:
9731
diff
changeset
|
45 |
static final boolean DEBUG_METHOD_HANDLE_NAMES; |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10419
diff
changeset
|
46 |
static final boolean DUMP_CLASS_FILES; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10419
diff
changeset
|
47 |
static final boolean TRACE_INTERPRETER; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10419
diff
changeset
|
48 |
static final boolean TRACE_METHOD_LINKAGE; |
40559
e727ba540ee6
8163371: Enable tracing which JLI classes can be pre-generated
redestad
parents:
40273
diff
changeset
|
49 |
static final boolean TRACE_RESOLVE; |
26467
d69abed3a07d
8050052: Small cleanups in java.lang.invoke code
vlivanov
parents:
26464
diff
changeset
|
50 |
static final int COMPILE_THRESHOLD; |
39483
3a7e016ba204
8160717: MethodHandles.loop() does not check for excessive signature
mhaupt
parents:
37781
diff
changeset
|
51 |
static final boolean LOG_LF_COMPILATION_FAILURE; |
27295
8ed31033bf48
8059877: GWT branch frequencies pollution due to LF sharing
vlivanov
parents:
26482
diff
changeset
|
52 |
static final int DONT_INLINE_THRESHOLD; |
26464
65b37da18e06
8037209: Improvements and cleanups to bytecode assembly for lambda forms
vlivanov
parents:
25859
diff
changeset
|
53 |
static final int PROFILE_LEVEL; |
29019
a859b806c8bd
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
27756
diff
changeset
|
54 |
static final boolean PROFILE_GWT; |
29020
9f6d43586ccb
8069591: Customize LambdaForms which are invoked using MH.invoke/invokeExact
vlivanov
parents:
29019
diff
changeset
|
55 |
static final int CUSTOMIZE_THRESHOLD; |
36934 | 56 |
static final boolean VAR_HANDLE_GUARDS; |
40273
46a0740b18e6
8163946: java/lang/String/concat/WithSecurityManager.java fails after 8163878
redestad
parents:
39483
diff
changeset
|
57 |
static final int MAX_ARITY; |
26464
65b37da18e06
8037209: Improvements and cleanups to bytecode assembly for lambda forms
vlivanov
parents:
25859
diff
changeset
|
58 |
|
9780
6fc3b49cfee4
7050328: (jsr-292) findConstructor throws ExceptionInInitializerError if run under SecurityManager
jrose
parents:
9731
diff
changeset
|
59 |
static { |
37781
71ed5645f17c
8155775: Re-examine naming of privileged methods to access System properties
redestad
parents:
37593
diff
changeset
|
60 |
Properties props = GetPropertyAction.privilegedGetProperties(); |
37593
824750ada3d6
8154231: Simplify access to System properties from JDK code
redestad
parents:
36934
diff
changeset
|
61 |
DEBUG_METHOD_HANDLE_NAMES = Boolean.parseBoolean( |
824750ada3d6
8154231: Simplify access to System properties from JDK code
redestad
parents:
36934
diff
changeset
|
62 |
props.getProperty("java.lang.invoke.MethodHandle.DEBUG_NAMES")); |
824750ada3d6
8154231: Simplify access to System properties from JDK code
redestad
parents:
36934
diff
changeset
|
63 |
DUMP_CLASS_FILES = Boolean.parseBoolean( |
824750ada3d6
8154231: Simplify access to System properties from JDK code
redestad
parents:
36934
diff
changeset
|
64 |
props.getProperty("java.lang.invoke.MethodHandle.DUMP_CLASS_FILES")); |
824750ada3d6
8154231: Simplify access to System properties from JDK code
redestad
parents:
36934
diff
changeset
|
65 |
TRACE_INTERPRETER = Boolean.parseBoolean( |
824750ada3d6
8154231: Simplify access to System properties from JDK code
redestad
parents:
36934
diff
changeset
|
66 |
props.getProperty("java.lang.invoke.MethodHandle.TRACE_INTERPRETER")); |
824750ada3d6
8154231: Simplify access to System properties from JDK code
redestad
parents:
36934
diff
changeset
|
67 |
TRACE_METHOD_LINKAGE = Boolean.parseBoolean( |
824750ada3d6
8154231: Simplify access to System properties from JDK code
redestad
parents:
36934
diff
changeset
|
68 |
props.getProperty("java.lang.invoke.MethodHandle.TRACE_METHOD_LINKAGE")); |
40559
e727ba540ee6
8163371: Enable tracing which JLI classes can be pre-generated
redestad
parents:
40273
diff
changeset
|
69 |
TRACE_RESOLVE = Boolean.parseBoolean( |
e727ba540ee6
8163371: Enable tracing which JLI classes can be pre-generated
redestad
parents:
40273
diff
changeset
|
70 |
props.getProperty("java.lang.invoke.MethodHandle.TRACE_RESOLVE")); |
37593
824750ada3d6
8154231: Simplify access to System properties from JDK code
redestad
parents:
36934
diff
changeset
|
71 |
COMPILE_THRESHOLD = Integer.parseInt( |
824750ada3d6
8154231: Simplify access to System properties from JDK code
redestad
parents:
36934
diff
changeset
|
72 |
props.getProperty("java.lang.invoke.MethodHandle.COMPILE_THRESHOLD", "0")); |
39483
3a7e016ba204
8160717: MethodHandles.loop() does not check for excessive signature
mhaupt
parents:
37781
diff
changeset
|
73 |
LOG_LF_COMPILATION_FAILURE = Boolean.parseBoolean( |
3a7e016ba204
8160717: MethodHandles.loop() does not check for excessive signature
mhaupt
parents:
37781
diff
changeset
|
74 |
props.getProperty("java.lang.invoke.MethodHandle.LOG_LF_COMPILATION_FAILURE", "false")); |
37593
824750ada3d6
8154231: Simplify access to System properties from JDK code
redestad
parents:
36934
diff
changeset
|
75 |
DONT_INLINE_THRESHOLD = Integer.parseInt( |
824750ada3d6
8154231: Simplify access to System properties from JDK code
redestad
parents:
36934
diff
changeset
|
76 |
props.getProperty("java.lang.invoke.MethodHandle.DONT_INLINE_THRESHOLD", "30")); |
824750ada3d6
8154231: Simplify access to System properties from JDK code
redestad
parents:
36934
diff
changeset
|
77 |
PROFILE_LEVEL = Integer.parseInt( |
824750ada3d6
8154231: Simplify access to System properties from JDK code
redestad
parents:
36934
diff
changeset
|
78 |
props.getProperty("java.lang.invoke.MethodHandle.PROFILE_LEVEL", "0")); |
824750ada3d6
8154231: Simplify access to System properties from JDK code
redestad
parents:
36934
diff
changeset
|
79 |
PROFILE_GWT = Boolean.parseBoolean( |
824750ada3d6
8154231: Simplify access to System properties from JDK code
redestad
parents:
36934
diff
changeset
|
80 |
props.getProperty("java.lang.invoke.MethodHandle.PROFILE_GWT", "true")); |
824750ada3d6
8154231: Simplify access to System properties from JDK code
redestad
parents:
36934
diff
changeset
|
81 |
CUSTOMIZE_THRESHOLD = Integer.parseInt( |
824750ada3d6
8154231: Simplify access to System properties from JDK code
redestad
parents:
36934
diff
changeset
|
82 |
props.getProperty("java.lang.invoke.MethodHandle.CUSTOMIZE_THRESHOLD", "127")); |
824750ada3d6
8154231: Simplify access to System properties from JDK code
redestad
parents:
36934
diff
changeset
|
83 |
VAR_HANDLE_GUARDS = Boolean.parseBoolean( |
824750ada3d6
8154231: Simplify access to System properties from JDK code
redestad
parents:
36934
diff
changeset
|
84 |
props.getProperty("java.lang.invoke.VarHandle.VAR_HANDLE_GUARDS", "true")); |
29020
9f6d43586ccb
8069591: Customize LambdaForms which are invoked using MH.invoke/invokeExact
vlivanov
parents:
29019
diff
changeset
|
85 |
|
40273
46a0740b18e6
8163946: java/lang/String/concat/WithSecurityManager.java fails after 8163878
redestad
parents:
39483
diff
changeset
|
86 |
// Do not adjust this except for special platforms: |
46a0740b18e6
8163946: java/lang/String/concat/WithSecurityManager.java fails after 8163878
redestad
parents:
39483
diff
changeset
|
87 |
MAX_ARITY = Integer.parseInt( |
46a0740b18e6
8163946: java/lang/String/concat/WithSecurityManager.java fails after 8163878
redestad
parents:
39483
diff
changeset
|
88 |
props.getProperty("java.lang.invoke.MethodHandleImpl.MAX_ARITY", "255")); |
46a0740b18e6
8163946: java/lang/String/concat/WithSecurityManager.java fails after 8163878
redestad
parents:
39483
diff
changeset
|
89 |
|
29020
9f6d43586ccb
8069591: Customize LambdaForms which are invoked using MH.invoke/invokeExact
vlivanov
parents:
29019
diff
changeset
|
90 |
if (CUSTOMIZE_THRESHOLD < -1 || CUSTOMIZE_THRESHOLD > 127) { |
9f6d43586ccb
8069591: Customize LambdaForms which are invoked using MH.invoke/invokeExact
vlivanov
parents:
29019
diff
changeset
|
91 |
throw newInternalError("CUSTOMIZE_THRESHOLD should be in [-1...127] range"); |
9f6d43586ccb
8069591: Customize LambdaForms which are invoked using MH.invoke/invokeExact
vlivanov
parents:
29019
diff
changeset
|
92 |
} |
9780
6fc3b49cfee4
7050328: (jsr-292) findConstructor throws ExceptionInInitializerError if run under SecurityManager
jrose
parents:
9731
diff
changeset
|
93 |
} |
9731
d0f7a3e441c4
7044892: JSR 292: API entry points sometimes throw the wrong exceptions or doesn't throw the expected one
jrose
parents:
9646
diff
changeset
|
94 |
|
24572
5c9e5961d21c
8037210: Get rid of char-based descriptions 'J' of basic types
vlivanov
parents:
16100
diff
changeset
|
95 |
/** Tell if any of the debugging switches are turned on. |
5c9e5961d21c
8037210: Get rid of char-based descriptions 'J' of basic types
vlivanov
parents:
16100
diff
changeset
|
96 |
* If this is the case, it is reasonable to perform extra checks or save extra information. |
5c9e5961d21c
8037210: Get rid of char-based descriptions 'J' of basic types
vlivanov
parents:
16100
diff
changeset
|
97 |
*/ |
5c9e5961d21c
8037210: Get rid of char-based descriptions 'J' of basic types
vlivanov
parents:
16100
diff
changeset
|
98 |
/*non-public*/ static boolean debugEnabled() { |
5c9e5961d21c
8037210: Get rid of char-based descriptions 'J' of basic types
vlivanov
parents:
16100
diff
changeset
|
99 |
return (DEBUG_METHOD_HANDLE_NAMES | |
5c9e5961d21c
8037210: Get rid of char-based descriptions 'J' of basic types
vlivanov
parents:
16100
diff
changeset
|
100 |
DUMP_CLASS_FILES | |
5c9e5961d21c
8037210: Get rid of char-based descriptions 'J' of basic types
vlivanov
parents:
16100
diff
changeset
|
101 |
TRACE_INTERPRETER | |
39483
3a7e016ba204
8160717: MethodHandles.loop() does not check for excessive signature
mhaupt
parents:
37781
diff
changeset
|
102 |
TRACE_METHOD_LINKAGE | |
3a7e016ba204
8160717: MethodHandles.loop() does not check for excessive signature
mhaupt
parents:
37781
diff
changeset
|
103 |
LOG_LF_COMPILATION_FAILURE); |
24572
5c9e5961d21c
8037210: Get rid of char-based descriptions 'J' of basic types
vlivanov
parents:
16100
diff
changeset
|
104 |
} |
5c9e5961d21c
8037210: Get rid of char-based descriptions 'J' of basic types
vlivanov
parents:
16100
diff
changeset
|
105 |
|
8821
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
106 |
// handy shared exception makers (they simplify the common case code) |
24572
5c9e5961d21c
8037210: Get rid of char-based descriptions 'J' of basic types
vlivanov
parents:
16100
diff
changeset
|
107 |
/*non-public*/ static InternalError newInternalError(String message) { |
5c9e5961d21c
8037210: Get rid of char-based descriptions 'J' of basic types
vlivanov
parents:
16100
diff
changeset
|
108 |
return new InternalError(message); |
5c9e5961d21c
8037210: Get rid of char-based descriptions 'J' of basic types
vlivanov
parents:
16100
diff
changeset
|
109 |
} |
42105
d04ede5f10e7
8163553: java.lang.LinkageError from test java/lang/ThreadGroup/Stop.java
psandoz
parents:
40559
diff
changeset
|
110 |
/*non-public*/ static InternalError newInternalError(String message, Exception cause) { |
14089
0a41b980d62a
8000989: smaller code changes to make future JSR 292 backports easier
twisti
parents:
13423
diff
changeset
|
111 |
return new InternalError(message, cause); |
0a41b980d62a
8000989: smaller code changes to make future JSR 292 backports easier
twisti
parents:
13423
diff
changeset
|
112 |
} |
42105
d04ede5f10e7
8163553: java.lang.LinkageError from test java/lang/ThreadGroup/Stop.java
psandoz
parents:
40559
diff
changeset
|
113 |
/*non-public*/ static InternalError newInternalError(Exception cause) { |
14089
0a41b980d62a
8000989: smaller code changes to make future JSR 292 backports easier
twisti
parents:
13423
diff
changeset
|
114 |
return new InternalError(cause); |
0a41b980d62a
8000989: smaller code changes to make future JSR 292 backports easier
twisti
parents:
13423
diff
changeset
|
115 |
} |
8821
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
116 |
/*non-public*/ static RuntimeException newIllegalStateException(String message) { |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
117 |
return new IllegalStateException(message); |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
118 |
} |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
119 |
/*non-public*/ static RuntimeException newIllegalStateException(String message, Object obj) { |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
120 |
return new IllegalStateException(message(message, obj)); |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
121 |
} |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
122 |
/*non-public*/ static RuntimeException newIllegalArgumentException(String message) { |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
123 |
return new IllegalArgumentException(message); |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
124 |
} |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
125 |
/*non-public*/ static RuntimeException newIllegalArgumentException(String message, Object obj) { |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
126 |
return new IllegalArgumentException(message(message, obj)); |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
127 |
} |
9646
5ebbe5ab084f
6939861: JVM should handle more conversion operations
jrose
parents:
8822
diff
changeset
|
128 |
/*non-public*/ static RuntimeException newIllegalArgumentException(String message, Object obj, Object obj2) { |
5ebbe5ab084f
6939861: JVM should handle more conversion operations
jrose
parents:
8822
diff
changeset
|
129 |
return new IllegalArgumentException(message(message, obj, obj2)); |
5ebbe5ab084f
6939861: JVM should handle more conversion operations
jrose
parents:
8822
diff
changeset
|
130 |
} |
26467
d69abed3a07d
8050052: Small cleanups in java.lang.invoke code
vlivanov
parents:
26464
diff
changeset
|
131 |
/** Propagate unchecked exceptions and errors, but wrap anything checked and throw that instead. */ |
14222 | 132 |
/*non-public*/ static Error uncaughtException(Throwable ex) { |
26467
d69abed3a07d
8050052: Small cleanups in java.lang.invoke code
vlivanov
parents:
26464
diff
changeset
|
133 |
if (ex instanceof Error) throw (Error) ex; |
d69abed3a07d
8050052: Small cleanups in java.lang.invoke code
vlivanov
parents:
26464
diff
changeset
|
134 |
if (ex instanceof RuntimeException) throw (RuntimeException) ex; |
42105
d04ede5f10e7
8163553: java.lang.LinkageError from test java/lang/ThreadGroup/Stop.java
psandoz
parents:
40559
diff
changeset
|
135 |
throw new InternalError("uncaught exception", ex); |
8821
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
136 |
} |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
137 |
private static String message(String message, Object obj) { |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
138 |
if (obj != null) message = message + ": " + obj; |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
139 |
return message; |
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
140 |
} |
9646
5ebbe5ab084f
6939861: JVM should handle more conversion operations
jrose
parents:
8822
diff
changeset
|
141 |
private static String message(String message, Object obj, Object obj2) { |
5ebbe5ab084f
6939861: JVM should handle more conversion operations
jrose
parents:
8822
diff
changeset
|
142 |
if (obj != null || obj2 != null) message = message + ": " + obj + ", " + obj2; |
5ebbe5ab084f
6939861: JVM should handle more conversion operations
jrose
parents:
8822
diff
changeset
|
143 |
return message; |
5ebbe5ab084f
6939861: JVM should handle more conversion operations
jrose
parents:
8822
diff
changeset
|
144 |
} |
48826 | 145 |
/*non-public*/ static void rangeCheck2(int start, int end, int size) { |
146 |
if (0 > start || start > end || end > size) |
|
147 |
throw new IndexOutOfBoundsException(start+".."+end); |
|
148 |
} |
|
149 |
/*non-public*/ static int rangeCheck1(int index, int size) { |
|
150 |
if (0 > index || index >= size) |
|
151 |
throw new IndexOutOfBoundsException(index); |
|
152 |
return index; |
|
153 |
} |
|
8821
2836ee97ee27
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
diff
changeset
|
154 |
} |