Community
Participate
Working Groups
When creating a jar with .class and .java files, WSWB generates an Null pointer exception. Steps to reproduce problem: 1. create a java project named "bug1" 2. extract the attached bug.jar to some temporary directory. 3. copy the java file Person.java and class files Person.class and Person_Pickler_Vj.class to the project "bug1" directory. select the bug1 project, and do a refresh from local. 4. do File/Export/Jar on project bug1, you should be able to get a NullPointerException. p.s. Note that Person_Pickler_Vj.class is IMPORTANT. This class file does not have corresponding source file.
Created attachment 171 [details] contains 2 .class files and 1 .java file
The stack trace I get is: Log: Thu Dec 13 15:01:21 EST 2001 4 org.eclipse.core.resources 368 Resource /P does not exist. Log: Thu Dec 13 15:04:45 EST 2001 4 org.eclipse.jdt.ui 1 Internal Error java.lang.reflect.InvocationTargetException: java.lang.NullPointerException at java.lang.String.<init>(String.java:210) at org.eclipse.jdt.internal.ui.jarpackager.JarFileExportOperation.buildJavaToClassM ap(JarFileExportOperation.java:391) at org.eclipse.jdt.internal.ui.jarpackager.JarFileExportOperation.filesOnClasspath( JarFileExportOperation.java:316) at org.eclipse.jdt.internal.ui.jarpackager.JarFileExportOperation.exportElement(Jar FileExportOperation.java:210) at org.eclipse.jdt.internal.ui.jarpackager.JarFileExportOperation.exportSelectedEle ments(JarFileExportOperation.java:282) at org.eclipse.jdt.internal.ui.jarpackager.JarFileExportOperation.singleRun(JarFile ExportOperation.java:520) at org.eclipse.jdt.internal.ui.jarpackager.JarFileExportOperation.run(JarFileExport Operation.java:502) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.jav a:98) The problem seems to be that inside JarFileExportOperation::buildJavaToClassMap method a call to sourceFileName()is done(String javaName= new String(cfReader.sourceFileName());). The method sourceFileName can return null. See the API on ClassFileReader: /** * (c)1998 Object Technology International. * (c)1998 International Business Machines Corporation. * * Answer the source file name attribute. Return null if there is no source file attribute for the receiver. * * @return char[] */ public char[] sourceFileName() { return this.sourceFileName; } And the null case is not handled properly. Suggest move to JDTUI.
I fixed the bug but most likely the result will not be the expected one i.e. the offending class file will not be packaged. How did this file go into the build directory? How generated it?If you have class files which are already there, I suggest to put them into a so-called class folder. This is supported by the JAR file exporter. Available in builds > 20011213