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 115185 - ClassCastException in NbEvents when using org.netbeans.modules.jnlpmodules.ClasspathModule
Summary: ClassCastException in NbEvents when using org.netbeans.modules.jnlpmodules.Cl...
Status: RESOLVED FIXED
Alias: None
Product: installer
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P4 blocker (vote)
Assignee: David Strupl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-10 20:45 UTC by David Strupl
Modified: 2007-09-17 23:03 UTC (History)
1 user (show)

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 David Strupl 2007-09-10 20:45:51 UTC
This happened in our 5.x based build

java.lang.ClassCastException
        at org.netbeans.core.startup.NbEvents.logged(NbEvents.java:207)
        at org.netbeans.Events.log(Events.java:133)
        at org.netbeans.Events.log(Events.java:159)
        at org.netbeans.modules.jnlpmodules.ClasspathModule.findExtensionsAndVariants(ClasspathModule.java:268)
        at org.netbeans.modules.jnlpmodules.ClasspathModule.<init>(ClasspathModule.java:104)
        at org.netbeans.modules.jnlpmodules.JNLPModuleFactory.createFixed(JNLPModuleFactory.java:85)
        at org.netbeans.ModuleManager.createFixed(ModuleManager.java:508)
        at org.netbeans.core.startup.ModuleSystem.loadBootModules(ModuleSystem.java:197)
        at org.netbeans.core.startup.Main.getModuleSystem(Main.java:210)
        at org.netbeans.core.startup.Main.start(Main.java:384)
        at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:90)
        at java.lang.Thread.run(Unknown Source)

but the code in question is still there. I will remove the unnecessary cast.
Comment 1 David Strupl 2007-09-10 20:46:41 UTC
Will do it myself.
Comment 2 David Strupl 2007-09-10 20:54:18 UTC
IDE: [10.9.07 21:48] Committing "NbEvents.java" started
Checking in NbEvents.java;
/cvs/core/startup/src/org/netbeans/core/startup/NbEvents.java,v  <--  NbEvents.java
new revision: 1.18; previous revision: 1.17
done
IDE: [10.9.07 21:48] Committing "NbEvents.java" finished
Comment 3 Jesse Glick 2007-09-10 22:06:00 UTC
I am uncomfortable with the patch. What is the actual type of args[1], if not Set<File>? Who is passing a different
type? The only usage of EXTENSION_MULTIPLY_LOADED I see is in StandardModule, which passes a Set<File>. Its definition
in Events also defines it to use Set<File> specifically.

installer/jnlp/modules/src/org/netbeans/modules/jnlpmodules/ClasspathModule.java passes a Set<String>, which is illegal
and should be fixed, but should not result in a CCE with the current code (which does not check the type of set members,
and due to erasure-based generics).
Comment 4 David Strupl 2007-09-11 08:40:56 UTC
Feel free to revert if you like. I have to fix 
installer/jnlp/modules/src/org/netbeans/modules/jnlpmodules/**
anyway since changes by Petr Nejedly has broken them even more.

Enforcing type safety using JavaDoc comment is not the best style IMHO and I thought that I could also ride on this hack
wave a bit ;-)

If you do revert please mention it here (and close this issue) so I know that I have to look at the ClasspathModule's
logging errors.

BTW Events creation is hardcoded so I have to either use the NbEvents or not to use it at all ...
Comment 5 Jesse Glick 2007-09-13 22:50:46 UTC
I reverted:

Checking in core/startup/src/org/netbeans/core/startup/NbEvents.java;
/shared/data/ccvs/repository/core/startup/src/org/netbeans/core/startup/NbEvents.java,v  <--  NbEvents.java
new revision: 1.19; previous revision: 1.18
done

Looking at it again, it seems that the immediate cause of the CCE is in fact passing a String for a File in args[0], not
the Set in args[1].

I don't like using Javadoc for type safety either, but Java lacks proper dependent types. Better would perhaps be to
create a class Event with a package-private no-arg constructor and one subclass per event with a type-safe public
constructor and getters.
Comment 6 David Strupl 2007-09-17 23:03:29 UTC
Fixed in ClasspathModule:

Checking in ClasspathModule.java;
/cvs/installer/jnlp/modules/src/org/netbeans/modules/jnlpmodules/ClasspathModule.java,v  <--  ClasspathModule.java
new revision: 1.9; previous revision: 1.8
done