Bug 39265 - [misc] Show wrong bytecode in navigator or editor
Summary: [misc] Show wrong bytecode in navigator or editor
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-06-24 06:48 EDT by Christophe Elek CLA
Modified: 2003-07-16 08:40 EDT (History)
0 users

See Also:


Attachments
JAR file containing 1 wrong bytecode (2.70 KB, application/x-zip-compressed)
2003-06-24 06:55 EDT, Christophe Elek CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christophe Elek CLA 2003-06-24 06:48:19 EDT
One customer had a JAR file that contained 2 .class file
One of the .class file is not a valid bytecode .class file (wrong magic number)
user does not know the bytecode is not valid. Can we have some error or warning
in the navigator (if the JAR is added as library) or in the bytecode editor (if
teh .class is opened) ?

I will attach teh JAR file.
1) create a Java project
2) add the JAR file in the library tab of the project's properties
3) expand the JAR
Comment 1 Christophe Elek CLA 2003-06-24 06:55:27 EDT
Created attachment 5284 [details]
JAR file containing 1 wrong bytecode
Comment 2 Dirk Baeumer CLA 2003-06-24 11:01:07 EDT
Asking JDT/Core for comments since they could provide error markers in these 
cases.
Comment 3 Olivier Thomann CLA 2003-06-24 11:17:27 EDT
On the second .class file that is actually a zip file (if you renamed it with
.zip , you can open it using Winzip), you actually get a ClassFormatException
when you try to open it.
In the class file editor (line 371), the UI is simply checking that the new
class file reader is not null. If it is null, it could report that the
corresponding file is not a valid .class file. This is specified on
org.eclipse.jdt.core.ToolFactory.createDefaultClassFileReader.
/**
 * Create a classfile reader onto a classfile Java element.
 * Create a default classfile reader, able to expose the internal representation
of a given classfile
 * according to the decoding flag used to initialize the reader.
 * Answer null if the file named fileName doesn't represent a valid .class file.
 * 
 * The decoding flags are described in IClassFileReader.
 * 
 * @param classfile the classfile element to introspect
 * @param decodingFlag the flag used to decode the class file reader.
 * @return a default classfile reader
 * 
 * @see IClassFileReader
 */
Comment 4 Olivier Thomann CLA 2003-06-24 12:40:16 EDT
The class file editor needs to be fixed on the JDT/UI side. We could improve the
error reporting of invalid .class file. For now the corresponding type is
reported as "cannot be resolved".