Bug 126332 - AIOOBE in classfile reader while exporting project in which annotations have arrays field
Summary: AIOOBE in classfile reader while exporting project in which annotations have ...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 M5   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-03 06:40 EST by Frederic Fusier CLA
Modified: 2006-05-05 14:36 EDT (History)
2 users (show)

See Also:


Attachments
Project which failed to export in jar file (8.13 KB, application/octet-stream)
2006-02-03 06:41 EST, Frederic Fusier CLA
no flags Details
Proposed patch (3.71 KB, patch)
2006-02-03 13:35 EST, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Frederic Fusier CLA 2006-02-03 06:40:53 EST
Fixing bug 124469 I got an AIOOBE while trying to export my test cases.

I'll attach the initial source project I wrote. Unzip it and try to export the project in a jar file.

You'll get following messages:
JAR creation failed. See details for additional information.
  class file(s) on classpath not found or not accessible /b124469/test/C.java
  Exported with compile warnings: /b124469/test/V.java
  class file(s) on classpath not found or not accessible /b124469/test/P.java
  class file(s) on classpath not found or not accessible /b124469/test/M.java
  class file(s) on classpath not found or not accessible /b124469/test/F.java
Comment 1 Frederic Fusier CLA 2006-02-03 06:41:36 EST
Created attachment 34067 [details]
Project which failed to export in jar file
Comment 2 Frederic Fusier CLA 2006-02-03 06:47:34 EST
Here's the stack trace I got in debugger:
ClassFileAttribute(ClassFileStruct).u4At(byte[], int, int) line: 64
ClassFileAttribute.<init>(byte[], IConstantPool, int) line: 30
ClassFileReader.<init>(byte[], int) line: 262
ToolFactory.createDefaultClassFileReader(InputStream, int) line: 195
JarFileExportOperation.buildJavaToClassMap(IContainer, IProgressMonitor) line: 727
JarFileExportOperation.filesOnClasspath(IFile, IPath, IJavaProject, IPackageFragmentRoot, IProgressMonitor) line: 651
JarFileExportOperation.exportClassFiles(IProgressMonitor, IPackageFragmentRoot, IResource, IJavaProject, IPath) line: 470
JarFileExportOperation.exportElement(Object, IProgressMonitor) line: 345
JarFileExportOperation.exportJavaElement(IProgressMonitor, IJavaElement) line: 361
JarFileExportOperation.exportElement(Object, IProgressMonitor) line: 275
JarFileExportOperation.exportJavaElement(IProgressMonitor, IJavaElement) line: 361
JarFileExportOperation.exportElement(Object, IProgressMonitor) line: 275
JarFileExportOperation.exportSelectedElements(IProgressMonitor) line: 495
JarFileExportOperation.singleRun(IProgressMonitor) line: 905
JarFileExportOperation.execute(IProgressMonitor) line: 881
WorkspaceModifyOperation$1.run(IProgressMonitor) line: 100
Workspace.run(IWorkspaceRunnable, ISchedulingRule, int, IProgressMonitor) line: 1733
JarFileExportOperation(WorkspaceModifyOperation).run(IProgressMonitor) line: 112
ModalContext$ModalContextThread.run() line: 113
Comment 3 Olivier Thomann CLA 2006-02-03 11:30:40 EST
The problem comes from the fact that we accept such code:
@interface A1 {
	E[] list();
}

enum E {
	A, B, C, D;
}
@A1(list = new E[] { E.A, E.C })
public class X {
	public static void main(String[] args) {
	}
}

An member value pair that is an array type can only be an array initializer. It cannot be an array creation expression. Syntactically this is fine since the array creation expression is seen as a condition expression.
javac reports:
X.java:8: new not allowed in an annotation
@A1(list = new E[] { E.A, E.C })
               ^
1 error
Comment 4 Olivier Thomann CLA 2006-02-03 12:09:09 EST
Philippe,

I have a fix for it that is released in HEAD. Do you want to backport to 3.1.x? I would say yes since the resulting .class file is completely boggus.

Fixed and released in HEAD.
Regression test added in org.eclipse.jdt.core.tests.compiler.regression.AnnotationTest.test188
Comment 5 Olivier Thomann CLA 2006-02-03 13:35:24 EST
Created attachment 34101 [details]
Proposed patch
Comment 6 Olivier Thomann CLA 2006-02-03 13:36:38 EST
If backported, the new constant in IProblem needs to be internal since no new API can be added.
Comment 7 David Audel CLA 2006-02-15 09:18:56 EST
Verified for 3.2 M5 using build I20060215-0010
Comment 8 Feng Xiang CLA 2006-05-05 12:56:46 EDT
Is it possible to backport this fix to Eclipse 3.0.2?
Comment 9 Olivier Thomann CLA 2006-05-05 12:59:41 EDT
3.0.2 doesn't contain a compiler that supports 1.5. So there is no need to backport to 3.0.2.
Comment 10 Feng Xiang CLA 2006-05-05 13:08:47 EDT
However we are getting the same JAR file exporting issue, when using SQLJ annotations in Java files.

class file(s) on classpath not found or not    accessible /Corebank/com/fnf/crb/accounting/batch/apdarentrycoderetroactv/DeleteEntryCode.java
class file(s) on classpath not found or not accessible /Corebank/com/fnf/crb/accounting/batch/apdarentrycoderetroactv/ReadBookValue.java
class file(s) on classpath not found or not accessible /Corebank/com/fnf/crb/accounting/batch/apdarownrshpprc2selsql/Ownership.java

These .class files does exist in the Resource view.

When testing on Eclipse 3.2 M6, the issue seems to be fixed.
Comment 11 Olivier Thomann CLA 2006-05-05 13:10:41 EDT
Are you talking about 3.0.2 or 3.1.2?
Comment 12 Feng Xiang CLA 2006-05-05 13:16:05 EDT
Using IBM Rational Application Developer, should be build on top of Eclipse 3.0.2.
Comment 13 Olivier Thomann CLA 2006-05-05 13:19:23 EDT
Then this is a different issue, because 3.0.2 code base is not aware of 1.5 features. The patch could not be applied to the 3.0.2 code base.
Comment 14 Feng Xiang CLA 2006-05-05 14:10:18 EDT
Do you recommend to create a bug for this issue?
Comment 15 Olivier Thomann CLA 2006-05-05 14:36:49 EDT
Certainly with steps to reproduce.