This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 15537 - Specify classloader in View2Support
Summary: Specify classloader in View2Support
Status: CLOSED FIXED
Alias: None
Product: debugger
Classification: Unclassified
Component: Code (show other bugs)
Version: 3.x
Hardware: Sun Solaris
: P3 blocker (vote)
Assignee: issues@debugger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-09-14 20:55 UTC by Torbjorn Norbye
Modified: 2001-10-05 15:29 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Torbjorn Norbye 2001-09-14 20:55:03 UTC
From tor@ha2mpk-mail.Eng.Sun.COM Fri Sep 14 12:52:14 2001
Date: Fri, 14 Sep 2001 12:51:37 -0700 (PDT)
From: Tor Norbye <tor@ha2mpk-mail.Eng.Sun.COM>
To: jan.jancura@sun.com, daniel.prusa@sun.com, marian.petras@sun.com
Cc: Tor Norbye <tor@norbye.Eng.Sun.COM>
Subject: New debugging window classloading

[ I will cut & paste this into a bug report for you to tracking
  purposes. ]



I tried adapting my module to work with the new window support.

It looks like the window creation is deferred now - that's great.

However, when I supply my own views, e.g. referring to my own
window objects ("com.sun.forte.developer.ipe.debugger.StackWindow"),
I get a ClassNotFoundException.

I think this is because the classloader used by the debuggercore
is not the same as the one used by my module (because the
debuggercore doesn't depend on my module), so the classloader
cannot find my code.

I had similar difficulty a while back when trying to use the AWT
"DataFlavor" class. The solution is that DataFlavor allows you
to specify a class loader to use.

So, can you add a fourth parameter to the view2support contructor
which lets me specify a fallback classloader? 

Here's the relevant method from DataFlavor.

   protected final static Class tryToLoadClass(String className,
                                                ClassLoader fallback)
        throws ClassNotFoundException
    {
({snip})
        try {
            return Class.forName(className, true, systemClassLoader);
        } catch (ClassNotFoundException e2) {
            if (fallback != null) {
                return Class.forName(className, true, fallback);
            } else {
                throw new ClassNotFoundException(className);
            }
        }
    }


E.g replace
        try {
            Class cls = Class.forName (component);
            return (TopComponent) cls.newInstance ();
        } catch (ClassNotFoundException e) {
            e.printStackTrace ();
        ...

with
        try {
            Class cls = Class.forName (component);
            return (TopComponent) cls.newInstance ();
        } catch (ClassNotFoundException e) {
            if (fallback != null) {
                return Class.forName(component, true, fallback);
            } else {
                throw new ClassNotFoundException(component);
            }
        ...


where 
  ClassLoader fallback
is a field in the view2support object, and in my case I'll
pass in  
    MyModuleInstall.class.getClassLoader()
as the fallback classloader.  (Alternatively, make all views
specify the classloader and use only the second forName to
find a class such that we don't throw 10 exceptions every
time debuggers defined outside of debuggercore start up!)
Comment 1 Jan Jancura 2001-09-17 17:54:30 UTC
View2Support uses system class loader, so it should work now.