Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4986512
Votes 0
Synopsis (cl) NoClassDefFoundError thrown when loading classes with names containing '/'
Category java:classes_lang
Reported Against tiger-beta
Release Fixed
State 11-Closed, Not a Defect, bug
Priority: 3-Medium
Related Bugs 6350076 , 5012884 , 5077272
Submit Date 30-JAN-2004
Description
  xxxxx@xxxxx   2004-01-30

J2SE Version (please include all output from java -version flag):
 java version "1.5.0-beta"
 Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32)
 Java HotSpot(TM) Client VM (build 1.5.0-beta-b32, mixed mode)

Does this problem occur on J2SE 1.3, 1.4 or 1.4.1?  Yes / No (pick one)
 No, works fine with 1.4.2

Bug Description:
  Customer has some code that generates classes on the fly, and loads them 
  (its a compiler for a scripting language).

  It works fine in JDK 1.4.2, but in 1.5.0, when it tries to load the
  newly generated class, it throws errors like the following:

java.lang.NoClassDefFoundError: IllegalName: factor/compiler/write__143
        at java.lang.ClassLoader.preDefineClass(ClassLoader.java:459)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:598)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:448)
        at factor.FactorWordDefinition$SimpleClassLoader._defineClass(FactorWordDefinition.java:257)
        at factor.FactorWordDefinition.compile(FactorWordDefinition.java:194)
        at factor.FactorWord.compile(FactorWord.java:74)
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:494)
        at factor.FactorJava.jinvoke(FactorJava.java:439)
        at factor.FactorPrimitive$P_jinvoke.eval(FactorPrimitive.java:365)
        at factor.FactorInterpreter.eval(FactorInterpreter.java:329)
        at factor.FactorInterpreter.run(FactorInterpreter.java:189)
        at factor.FactorInterpreter.runBootstrap(FactorInterpreter.java:150)
        at factor.FactorInterpreter.init(FactorInterpreter.java:118)
        at factor.FactorInterpreter.main(FactorInterpreter.java:76)

Step to Reproduce:
  Hard to get a narrow down test case. just attached a zip file which
  contains 143 automatically generated classes. They all work fine with
  1.4.2, but in 1.5 they all fail to load with an error; check the above
  stack traces.


  xxxxx@xxxxx   2004- customer -03

Test case attached - ASMTest.jar.

run java ASMTest and get the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: IllegalName: foo/bar/baz/quux
        at java.lang.ClassLoader.preDefineClass(ClassLoader.java:459)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:598)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:448)
        at ASMTest$SimpleClassLoader._defineClass(ASMTest.java:46)
        at ASMTest.main(ASMTest.java:30)


but, works fine with 1.4.2.
Work Around
N/A
Evaluation
This is the intended behaviour.

Since ClassLoader.defineClass was introduced in jdk1.1, this has been the specification for the syntax of the expected class name:

     @param  name
             The expected name of the class, or null if not known, using
             '.' and not '/' as the separator and without a trailing ".class"
             suffix.

In jdk1.5 we modified the implemenation of ClassLoader and have improved
parameter checking for this method.

As the detail message of the exception indicates, the provided class name is
illegal. The code which calls defineClass should be modified to use '.' as the
separator for the class name.

--   xxxxx@xxxxx   2004-02-04
Comments
  
  Include a link with my name & email   

Submitted On 06-OCT-2005
Khadar
how to resolve this problem from the developer side?


Submitted On 13-NOV-2005
jackass2600
One way to work around this is to patch the version of java/lang/ClassLoader in rt.jar and prepend it to your boot class path. Or (more appropriately) fix the offending caller that is using the wrong form of the class name ;-)



PLEASE NOTE: JDK6 is formerly known as Project Mustang