[hg] main-silver: #223671: Retrieve the bootstrap class loader t...

  • From:
  • To:
  • Subject: [hg] main-silver: #223671: Retrieve the bootstrap class loader t...
  • Date: Wed, 09 Jan 2013 09:57:51 -0800

changeset 00aac942e330 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/00aac942e330
description:
        #223671: Retrieve the bootstrap class loader to load our services on.

diffstat:

 
debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/RemoteServices.java
 |  36 ++++++---
 1 files changed, 25 insertions(+), 11 deletions(-)

diffs (69 lines):

diff --git 
a/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/RemoteServices.java
 
b/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/RemoteServices.java
--- 
a/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/RemoteServices.java
+++ 
b/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/RemoteServices.java
@@ -44,6 +44,7 @@
 import com.sun.jdi.ArrayReference;
 import com.sun.jdi.ArrayType;
 import com.sun.jdi.BooleanValue;
+import com.sun.jdi.ClassLoaderReference;
 import com.sun.jdi.ClassNotLoadedException;
 import com.sun.jdi.ClassObjectReference;
 import com.sun.jdi.ClassType;
@@ -152,18 +153,37 @@
         }
     }
     
+    private static ObjectReference getBootstrapClassLoader(ThreadReference 
tawt, VirtualMachine vm) throws InvalidTypeException, 
ClassNotLoadedException, IncompatibleThreadStateException, 
InvocationException, IOException, PropertyVetoException, 
InternalExceptionWrapper, VMDisconnectedExceptionWrapper, 
ObjectCollectedExceptionWrapper, UnsupportedOperationExceptionWrapper, 
ClassNotPreparedExceptionWrapper {
+        /* Run this code:
+            ClassLoader cl = ClassLoader.getSystemClassLoader();
+            ClassLoader bcl;
+            do {
+                bcl = cl;
+                cl = cl.getParent();
+            } while (cl != null);
+            return bcl;
+         */
+        ClassType classLoaderClass = getClass(vm, 
ClassLoader.class.getName());
+        Method getSystemClassLoader = 
ClassTypeWrapper.concreteMethodByName(classLoaderClass, 
"getSystemClassLoader", "()Ljava/lang/ClassLoader;");
+        ObjectReference cl = (ObjectReference) 
ClassTypeWrapper.invokeMethod(classLoaderClass, tawt, getSystemClassLoader, 
Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);
+        Method getParent = 
ClassTypeWrapper.concreteMethodByName(classLoaderClass, "getParent", 
"()Ljava/lang/ClassLoader;");
+        ObjectReference bcl;
+        do {
+            bcl = cl;
+            cl = (ObjectReference) ObjectReferenceWrapper.invokeMethod(cl, 
tawt, getParent, Collections.EMPTY_LIST, 
ObjectReference.INVOKE_SINGLE_THREADED);
+        } while (cl != null);
+        return bcl;
+    }
+    
     public static ClassObjectReference uploadBasicClasses(JPDAThreadImpl t, 
ServiceType sType) throws InvalidTypeException, ClassNotLoadedException, 
IncompatibleThreadStateException, InvocationException, IOException, 
PropertyVetoException, InternalExceptionWrapper, 
VMDisconnectedExceptionWrapper, ObjectCollectedExceptionWrapper, 
UnsupportedOperationExceptionWrapper, ClassNotPreparedExceptionWrapper {
         ThreadReference tawt = t.getThreadReference();
         VirtualMachine vm = tawt.virtualMachine();
         
-        ReferenceType threadType = tawt.referenceType();
-        Method getContextCl = 
ClassTypeWrapper.concreteMethodByName((ClassType) threadType, 
"getContextClassLoader", "()Ljava/lang/ClassLoader;");
         t.notifyMethodInvoking();
         try {
             ClassObjectReference basicClass = null;
             t.accessLock.writeLock().lock();
             try {
-                ObjectReference cl = (ObjectReference) 
ObjectReferenceWrapper.invokeMethod(tawt, tawt, getContextCl, 
Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);
                 List<RemoteClass> remoteClasses = getRemoteClasses();
                 for (RemoteClass rc : remoteClasses) {
                     String className = rc.name;
@@ -180,14 +200,8 @@
                 }
                 // Suppose that when there's the basic class loaded, there 
are all.
                 if (basicClass == null) {  // Load the classes only if 
there's not the basic one.
-                    ClassType classLoaderClass = null;
-                    if (cl != null) {
-                        classLoaderClass = (ClassType) 
ObjectReferenceWrapper.referenceType(cl);
-                    } else {
-                        classLoaderClass = getClass(vm, 
ClassLoader.class.getName());
-                        Method getSystemClassLoader = 
ClassTypeWrapper.concreteMethodByName(classLoaderClass, 
"getSystemClassLoader", "()Ljava/lang/ClassLoader;");
-                        cl = (ObjectReference) 
ClassTypeWrapper.invokeMethod(classLoaderClass, tawt, getSystemClassLoader, 
Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);
-                    }
+                    ObjectReference cl = getBootstrapClassLoader(tawt, vm);
+                    ClassType classLoaderClass = (ClassType) 
ObjectReferenceWrapper.referenceType(cl);
 
                     for (RemoteClass rc : remoteClasses) {
                         String className = rc.name;

[hg] main-silver: #223671: Retrieve the bootstrap class loader t...

mentlicher 01/09/2013

Project Features

About this Project

Debugger was started in November 2009, is owned by tpavek, and has 29 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close