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.
Summary: | Cannot create instance of desired class. | ||
---|---|---|---|
Product: | java | Reporter: | _ sormuras <sormuras> |
Component: | Unsupported | Assignee: | Tomas Hurka <thurka> |
Status: | CLOSED FIXED | ||
Severity: | blocker | CC: | dstrupl, jtulach, phamernik, tpavek |
Priority: | P3 | ||
Version: | 3.x | ||
Hardware: | PC | ||
OS: | Windows ME/2000 | ||
Issue Type: | DEFECT | Exception Reporter: | |
Attachments: |
"MyMemoryView" log output
Inner-class-specialized-OIS-patch-proposal |
Description
_ sormuras
2002-02-28 22:22:38 UTC
Created attachment 4876 [details]
"MyMemoryView" log output
This part of code is located in OpenIDE part. Not beans module job. Tried to switch from JDK 1.4 back to JDK 1.3.1 but that did not help. I think the problem is in that InstanceSupport.instanceCreate uses NbObjectInputStream for desrialization which uses systemClassLoader (and not currentClassLoader)... I see two possible fixes - as I'm still not too deep in the sources, I might propose the wrong solutions. Anyway, here they are: 1. Use another ObjectInputStream implementation, that utilizes the currentClassLoader or 2. make NbObjectInputStream use the currentClassLoader. [org.openide.util.io.NbObjectInputStream:67] private static ClassLoader getNBClassLoader() { /**/ClassLoader c = (ClassLoader)Lookup.getDefault ().lookup (ClassLoader.class); return c != null ? c : ClassLoader.getSystemClassLoader (); } Should the first line return the currentClassLoader? Or in other words, how to lookup the currentClassLoader? Forcing the above method "getNBClassLoader()" to... { return TopManager.getDefault().currentClassLoader(); } ...fixes the bug. Does it break anything? Created attachment 4921 [details]
Inner-class-specialized-OIS-patch-proposal
This patch is just a "higher-level" solution to the May be it is way of cleaner to create a new file that contains a class extending "NbObjectInputStream". Was suggested on dev@openide that the bug is in clazz module for using InstanceSupport for user *.ser (and *.class) files. Or if it uses InstanceSupport, it should use a subclass which selects currentClassLoader. NbObjectInputStream must not refer to TopManager because of API separation. I think that the patch of InstanceSupport is fine. Should we move the issue to openide/datasystems? It is not fine, it is a workaround. When I was suggesting that solution, I was talking about choosing CL by the domain the serialized file came from. If I have a serialized file in my system userdir (say a compiler), I really don't like the IDE loading *repository* classes when I hit <Compile>. The problem should be either fixed in clazz module or the patch need to be enhanced to do source domain checking and providing proper CL for each domain. I will try to fix it in Clazz module. Fixed in clazz module. Deseralization uses currentClassLoader. VERIFIED Resolved for 3.3.x or earlier, no new info since then -> closing. |