@@ -213,40 +213,7 @@ private static boolean forName(JNIEnvironment jni, JNIObjectHandle thread, Break
213
213
if (className == null ) {
214
214
return false ; /* No point in tracing this. */
215
215
}
216
-
217
- boolean classLoaderValid = true ;
218
- WordPointer classLoaderPtr = StackValue .get (WordPointer .class );
219
- if (bp .method == agent .handles ().javaLangClassForName3 ) {
220
- assert thread .notEqual (nullHandle ()) || Support .jvmtiVersion () != JvmtiInterface .JVMTI_VERSION_19 : "JDK-8292657" ;
221
- classLoaderValid = (jvmtiFunctions ().GetLocalObject ().invoke (jvmtiEnv (), thread , 0 , 2 , classLoaderPtr ) == JvmtiError .JVMTI_ERROR_NONE );
222
- } else {
223
- classLoaderPtr .write (nullHandle ());
224
- if (callerClass .notEqual (nullHandle ())) {
225
- /*
226
- * NOTE: we use our direct caller class, but this class might be skipped over by
227
- * Class.forName(nameOnly) in its security stackwalk for @CallerSensitive, leading
228
- * to different behavior of our call and the original call.
229
- */
230
- classLoaderValid = (jvmtiFunctions ().GetClassLoader ().invoke (jvmtiEnv (), callerClass , classLoaderPtr ) == JvmtiError .JVMTI_ERROR_NONE );
231
- }
232
- }
233
- Object result = Tracer .UNKNOWN_VALUE ;
234
- if (classLoaderValid ) {
235
- /*
236
- * Even if the original call requested class initialization, disable it because
237
- * recursion checks keep us from seeing events of interest during initialization.
238
- */
239
- int initialize = 0 ;
240
- Support .callStaticObjectMethodLIL (jni , bp .clazz , agent .handles ().javaLangClassForName3 , name , initialize , classLoaderPtr .read ());
241
- JNIObjectHandle exception = handleException (jni , true );
242
- /*
243
- * To throw the right exceptions at run time, we need to ensure that the image builder
244
- * sees them, so we trace all calls except those that throw a ClassNotFoundException.
245
- */
246
- result = exception .equal (nullHandle ()) || !jniFunctions ().getIsInstanceOf ().invoke (jni , exception , agent .handles ().javaLangClassNotFoundException );
247
- }
248
-
249
- traceReflectBreakpoint (jni , bp .clazz , nullHandle (), callerClass , bp .specification .methodName , result , state .getFullStackTraceOrNull (), className );
216
+ traceReflectBreakpoint (jni , bp .clazz , nullHandle (), callerClass , bp .specification .methodName , null , state .getFullStackTraceOrNull (), className );
250
217
return true ;
251
218
}
252
219
@@ -298,10 +265,22 @@ private static boolean getDeclaredClasses(JNIEnvironment jni, JNIObjectHandle th
298
265
return handleGetClasses (jni , thread , bp , state );
299
266
}
300
267
268
+ private static boolean getRecordComponents (JNIEnvironment jni , JNIObjectHandle thread , Breakpoint bp , InterceptedState state ) {
269
+ return handleGetClasses (jni , thread , bp , state );
270
+ }
271
+
301
272
private static boolean getPermittedSubclasses (JNIEnvironment jni , JNIObjectHandle thread , Breakpoint bp , InterceptedState state ) {
302
273
return handleGetClasses (jni , thread , bp , state );
303
274
}
304
275
276
+ private static boolean getNestMembers (JNIEnvironment jni , JNIObjectHandle thread , Breakpoint bp , InterceptedState state ) {
277
+ return handleGetClasses (jni , thread , bp , state );
278
+ }
279
+
280
+ private static boolean getSigners (JNIEnvironment jni , JNIObjectHandle thread , Breakpoint bp , InterceptedState state ) {
281
+ return handleGetClasses (jni , thread , bp , state );
282
+ }
283
+
305
284
private static boolean handleGetClasses (JNIEnvironment jni , JNIObjectHandle thread , Breakpoint bp , InterceptedState state ) {
306
285
JNIObjectHandle callerClass = state .getDirectCallerClass ();
307
286
JNIObjectHandle self = getReceiver (thread );
@@ -332,7 +311,7 @@ private static boolean handleGetField(JNIEnvironment jni, JNIObjectHandle thread
332
311
declaring = nullHandle ();
333
312
}
334
313
}
335
- traceReflectBreakpoint (jni , getClassOrSingleProxyInterface (jni , self ), getClassOrSingleProxyInterface (jni , declaring ), callerClass , bp .specification .methodName , result . notEqual ( nullHandle ()) ,
314
+ traceReflectBreakpoint (jni , getClassOrSingleProxyInterface (jni , self ), getClassOrSingleProxyInterface (jni , declaring ), callerClass , bp .specification .methodName , true ,
336
315
state .getFullStackTraceOrNull (), fromJniString (jni , name ));
337
316
return true ;
338
317
}
@@ -395,12 +374,8 @@ private static boolean getConstructor(JNIEnvironment jni, JNIObjectHandle thread
395
374
JNIObjectHandle callerClass = state .getDirectCallerClass ();
396
375
JNIObjectHandle self = getReceiver (thread );
397
376
JNIObjectHandle paramTypesHandle = getObjectArgument (thread , 1 );
398
- JNIObjectHandle result = Support .callObjectMethodL (jni , self , bp .method , paramTypesHandle );
399
- if (clearException (jni )) {
400
- result = nullHandle ();
401
- }
402
377
Object paramTypes = getClassArrayNames (jni , paramTypesHandle );
403
- traceReflectBreakpoint (jni , getClassOrSingleProxyInterface (jni , self ), nullHandle (), callerClass , bp .specification .methodName , nullHandle (). notEqual ( result ) , state .getFullStackTraceOrNull (),
378
+ traceReflectBreakpoint (jni , getClassOrSingleProxyInterface (jni , self ), nullHandle (), callerClass , bp .specification .methodName , true , state .getFullStackTraceOrNull (),
404
379
paramTypes );
405
380
return true ;
406
381
}
@@ -431,7 +406,7 @@ private static boolean handleGetMethod(JNIEnvironment jni, JNIObjectHandle threa
431
406
}
432
407
String name = fromJniString (jni , nameHandle );
433
408
Object paramTypes = getClassArrayNames (jni , paramTypesHandle );
434
- traceReflectBreakpoint (jni , getClassOrSingleProxyInterface (jni , self ), getClassOrSingleProxyInterface (jni , declaring ), callerClass , bp .specification .methodName , result . notEqual ( nullHandle ()) ,
409
+ traceReflectBreakpoint (jni , getClassOrSingleProxyInterface (jni , self ), getClassOrSingleProxyInterface (jni , declaring ), callerClass , bp .specification .methodName , true ,
435
410
state .getFullStackTraceOrNull (), name , paramTypes );
436
411
return true ;
437
412
}
@@ -1799,8 +1774,14 @@ private interface BreakpointHandler {
1799
1774
optionalBrk ("java/lang/invoke/MethodType" , "fromMethodDescriptorString" ,
1800
1775
"(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljava/lang/invoke/MethodType;" ,
1801
1776
BreakpointInterceptor ::methodTypeFromDescriptor ),
1777
+ optionalBrk ("java/lang/Class" , "getRecordComponents" , "()[Ljava/lang/reflect/RecordComponent;" ,
1778
+ BreakpointInterceptor ::getRecordComponents ),
1802
1779
optionalBrk ("java/lang/Class" , "getPermittedSubclasses" , "()[Ljava/lang/Class;" ,
1803
- BreakpointInterceptor ::getPermittedSubclasses )
1780
+ BreakpointInterceptor ::getPermittedSubclasses ),
1781
+ optionalBrk ("java/lang/Class" , "getNestMembers" , "()[Ljava/lang/Class;" ,
1782
+ BreakpointInterceptor ::getNestMembers ),
1783
+ optionalBrk ("java/lang/Class" , "getSigners" , "()[Ljava/lang/Object;" ,
1784
+ BreakpointInterceptor ::getSigners )
1804
1785
};
1805
1786
1806
1787
private static boolean allocateInstance (JNIEnvironment jni , JNIObjectHandle thread , @ SuppressWarnings ("unused" ) Breakpoint bp , InterceptedState state ) {
0 commit comments