DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4464>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4464 patch: jar-packaged translet-classname built with wrong slash on windows platform Summary: patch: jar-packaged translet-classname built with wrong slash on windows platform Product: XalanJ2 Version: CurrentCVS Platform: PC OS/Version: Windows NT/2K Status: NEW Severity: Normal Priority: Other Component: org.apache.xalan.xsltc AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] When compiling and packaging a translet to a jar file in windows \ is used for both filesystem access and any jar-packaged classnames. This is incorrect behaviour, / should always be used in constructing the jar-packaged classnames regardless of platform. repro steps ----------- C:\local>java org.apache.xalan.xsltc.cmdline.Compile -p com.schemasoft -o Table -j foo.jar Table.xsl C:\local>jar tf foo.jar * com\schemasoft\Table$0.class com\schemasoft\Table$1.class com\schemasoft\Table.class C:\local>java -classpath foo.jar com.schemasoft.Table Exception in thread "main" java.lang.NoClassDefFoundError: com/schemasoft/Table Notice that java was looking for "com/schemasoft/Table" and not finding it since the class is named "com\schemasoft\Table" (ie the wrong slash was used when constructing the JarEntry). patch ----- --- XSLTC.java 2001/10/26 09:38:06 1.30 +++ XSLTC.java 2001/10/26 20:45:33 @@ -475,6 +475,14 @@ } /** + * Convert for Java class name to jar file name. + * (Replace '.' with '/' for jarnames on all platforms) + */ + private String classJarFileName(final String className) { + return className.replace('.', '/') + ".class"; + } + + /** * Generate an output File object to send the translet to */ private File getOutputFile(String className) { @@ -700,7 +708,7 @@ classes = _classes.elements(); while (classes.hasMoreElements()) { final JavaClass cl = (JavaClass)classes.nextElement(); - jos.putNextEntry(new JarEntry(classFileName(cl.getClassName()))); + jos.putNextEntry(new JarEntry(classJarFileName(cl.getClassName()))); final ByteArrayOutputStream out = new ByteArrayOutputStream(2048); cl.dump(out); // dump() closes it's output stream out.writeTo(jos);