diff --git a/substratevm/src/com.oracle.svm.agent/src/com/oracle/svm/agent/BreakpointInterceptor.java b/substratevm/src/com.oracle.svm.agent/src/com/oracle/svm/agent/BreakpointInterceptor.java index 34e790a80211..5b80efb48709 100644 --- a/substratevm/src/com.oracle.svm.agent/src/com/oracle/svm/agent/BreakpointInterceptor.java +++ b/substratevm/src/com.oracle.svm.agent/src/com/oracle/svm/agent/BreakpointInterceptor.java @@ -758,18 +758,21 @@ private static boolean newArrayInstance0(JNIEnvironment jni, Breakpoint bp, JNIV return true; } - private static boolean handleResourceRegistration(JNIEnvironment env, JNIObjectHandle clazz, JNIObjectHandle callerClass, String function, JNIMethodId[] stackTrace, String resourceName, - String moduleName) { + private static boolean handleResourceRegistration(JNIEnvironment env, JNIObjectHandle clazz, JNIObjectHandle callerClass, String function, JNIMethodId[] stackTrace, String resourceName) { if (resourceName == null) { return true; /* No point in tracing this: resource path is null */ } + traceReflectBreakpoint(env, clazz, nullHandle(), callerClass, function, true, stackTrace, resourceName); + return true; + } - if (moduleName == null) { - traceReflectBreakpoint(env, clazz, nullHandle(), callerClass, function, true, stackTrace, resourceName); - } else { - traceReflectBreakpoint(env, clazz, nullHandle(), callerClass, function, true, stackTrace, moduleName, resourceName); + private static boolean handleResourceRegistrationWithModuleName(JNIEnvironment env, JNIObjectHandle clazz, JNIObjectHandle callerClass, String function, JNIMethodId[] stackTrace, + String resourceName, + String moduleName) { + if (resourceName == null) { + return true; /* No point in tracing this: resource path is null */ } - + traceReflectBreakpoint(env, clazz, nullHandle(), callerClass, function, true, stackTrace, moduleName, resourceName); return true; } @@ -778,7 +781,8 @@ private static boolean findResource(JNIEnvironment jni, JNIObjectHandle thread, JNIObjectHandle module = getObjectArgument(thread, 1); JNIObjectHandle name = getObjectArgument(thread, 2); - return handleResourceRegistration(jni, nullHandle(), callerClass, bp.specification.methodName, state.getFullStackTraceOrNull(), fromJniString(jni, name), fromJniString(jni, module)); + return handleResourceRegistrationWithModuleName(jni, nullHandle(), callerClass, bp.specification.methodName, state.getFullStackTraceOrNull(), fromJniString(jni, name), + fromJniString(jni, module)); } private static boolean getResource(JNIEnvironment jni, JNIObjectHandle thread, Breakpoint bp, InterceptedState state) { @@ -801,7 +805,7 @@ private static boolean handleGetResources(JNIEnvironment jni, JNIObjectHandle th } } - return handleResourceRegistration(jni, selfClazz, callerClass, bp.specification.methodName, state.getFullStackTraceOrNull(), fromJniString(jni, name), null); + return handleResourceRegistration(jni, selfClazz, callerClass, bp.specification.methodName, state.getFullStackTraceOrNull(), fromJniString(jni, name)); } private static boolean getSystemResource(JNIEnvironment jni, JNIObjectHandle thread, Breakpoint bp, InterceptedState state) { @@ -816,7 +820,7 @@ private static boolean handleGetSystemResources(JNIEnvironment jni, JNIObjectHan JNIObjectHandle callerClass = state.getDirectCallerClass(); JNIObjectHandle name = getObjectArgument(thread, 0); - return handleResourceRegistration(jni, nullHandle(), callerClass, bp.specification.methodName, state.getFullStackTraceOrNull(), fromJniString(jni, name), null); + return handleResourceRegistration(jni, nullHandle(), callerClass, bp.specification.methodName, state.getFullStackTraceOrNull(), fromJniString(jni, name)); } private static boolean getZipEntry(JNIEnvironment jni, JNIObjectHandle thread, Breakpoint bp, InterceptedState state) { @@ -836,7 +840,7 @@ private static boolean getZipEntry(JNIEnvironment jni, JNIObjectHandle thread, B } JNIObjectHandle zipFileReceiver = getReceiver(thread); String zipFileName = fromJniString(jni, Support.callObjectMethod(jni, zipFileReceiver, agent.handles().getJavaUtilZipZipFileGetName(jni))); - if (!agent.classPathEntries.contains(zipFileName)) { + if (zipFileName == null || !agent.classPathEntries.contains(zipFileName)) { return true; } @@ -846,7 +850,7 @@ private static boolean getZipEntry(JNIEnvironment jni, JNIObjectHandle thread, B } JNIObjectHandle callerClass = state.getDirectCallerClass(); - return handleResourceRegistration(jni, selfClazz, callerClass, bp.specification.methodName, state.getFullStackTraceOrNull(), name, null); + return handleResourceRegistration(jni, selfClazz, callerClass, bp.specification.methodName, state.getFullStackTraceOrNull(), name); } private static boolean newProxyInstance(JNIEnvironment jni, JNIObjectHandle thread, Breakpoint bp, InterceptedState state) {