Bug 6903 - 1GOMQ6H:- NullPointerException when exporting to a jar
Summary: 1GOMQ6H:- NullPointerException when exporting to a jar
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 1.0   Edit
Hardware: PC Windows 2000
: P1 normal (vote)
Target Milestone: ---   Edit
Assignee: Dani Megert CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-12-13 14:16 EST by OTI Support CLA
Modified: 2001-12-14 08:23 EST (History)
0 users

See Also:


Attachments
contains 2 .class files and 1 .java file (1.86 KB, application/octet-stream)
2001-12-13 14:17 EST, OTI Support CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description OTI Support CLA 2001-12-13 14:16:02 EST
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.
Comment 1 OTI Support CLA 2001-12-13 14:17:02 EST
Created attachment 171 [details]
contains 2 .class files and 1 .java file
Comment 2 Olivier Thomann CLA 2001-12-13 15:01:39 EST
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.
Comment 3 Dani Megert CLA 2001-12-14 08:23:46 EST
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