Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 497218 - [1.9] Cannot index SecurityManager.class and JApplet.class
Summary: [1.9] Cannot index SecurityManager.class and JApplet.class
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.6   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: BETA J9   Edit
Assignee: Jay Arthanareeswaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 497597 520168 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-07-04 04:12 EDT by Noopur Gupta CLA
Modified: 2017-07-26 11:47 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Noopur Gupta CLA 2016-07-04 04:12:46 EDT
jdk-9-ea+123

Getting the following warnings in Error Log view:

The Java indexing could not index C:/Eclipse/JREs/jdk-9-ea+123_windows-x64_bin/jdk9/jdk-9/jrt-fs.jar|java.base|java/lang/SecurityManager.class. This .class file doesn't follow the class file format specification. Please report this issue against the .class file vendor

The Java indexing could not index C:/Eclipse/JREs/jdk-9-ea+123_windows-x64_bin/jdk9/jdk-9/jrt-fs.jar|java.desktop|javax/swing/JApplet.class. This .class file doesn't follow the class file format specification. Please report this issue against the .class file vendor

Also, the following code gives error ("SecurityManager cannot be resolved to a type") in a Java 9 project:


import java.lang.SecurityManager;

public class C {
	SecurityManager s;
}
Comment 1 Jay Arthanareeswaran CLA 2016-07-04 04:39:42 EDT
I see the exception, let me take a look.
Comment 2 Jay Arthanareeswaran CLA 2016-07-04 04:46:49 EDT
Here's the exception that seems to halt the indexer and compiler:

java.lang.IllegalStateException
	at org.eclipse.jdt.internal.compiler.classfmt.AnnotationInfo.scanElementValue(AnnotationInfo.java:375)
	at org.eclipse.jdt.internal.compiler.classfmt.AnnotationInfo.scanAnnotation(AnnotationInfo.java:334)
	at org.eclipse.jdt.internal.compiler.classfmt.AnnotationInfo.<init>(AnnotationInfo.java:51)
	at org.eclipse.jdt.internal.compiler.classfmt.MethodInfo.decodeAnnotations(MethodInfo.java:140)
	at org.eclipse.jdt.internal.compiler.classfmt.MethodInfo.decodeMethodAnnotations(MethodInfo.java:148)
	at org.eclipse.jdt.internal.compiler.classfmt.MethodInfo.createMethod(MethodInfo.java:67)
	at org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.<init>(ClassFileReader.java:319)
	at org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.<init>(ClassFileReader.java:168)
	at org.eclipse.jdt.internal.compiler.util.JrtFileSystem.getClassfile(JRTUtil.java:235)
	at org.eclipse.jdt.internal.compiler.util.JrtFileSystem.getClassfile(JRTUtil.java:272)
	at org.eclipse.jdt.internal.compiler.util.JRTUtil.getClassfile(JRTUtil.java:154)
	at org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.readFromJrt(ClassFileReader.java:140)
	at org.eclipse.jdt.internal.core.builder.ClasspathJrt.findClass(ClasspathJrt.java:192)
	at org.eclipse.jdt.internal.core.builder.NameEnvironment.findClass(NameEnvironment.java:324)
Comment 3 Jay Arthanareeswaran CLA 2016-07-04 05:33:35 EDT
And the affected part is the following annotation on the checkMemberAccess() method:

 @Deprecated(since="1.8", forRemoval=true)

My guess at this point is the newly added attributes in @Deprecated in Java 9 are not accounted for.
Comment 4 Jay Arthanareeswaran CLA 2016-07-04 12:12:07 EDT
Fix released via:

http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA9&id=ce8c193d2aef1a09a49f2f42720cb83268a87baf

The fix is in AnnotationInfo#scanAnnotation() to not return immediately but only after iterating through the annotation values. One might want to make use of the new attributes added to the annotation (namely since() and forRemoval()) to add more details to the error reporting. But that can be taken up later as an enhancement.
Comment 5 Jay Arthanareeswaran CLA 2016-07-19 21:41:13 EDT
*** Bug 497597 has been marked as a duplicate of this bug. ***
Comment 6 Keith W. Campbell CLA 2017-07-26 10:45:56 EDT
*** Bug 520168 has been marked as a duplicate of this bug. ***
Comment 7 Stephan Herrmann CLA 2017-07-26 11:47:29 EDT
For the records:

(In reply to Jay Arthanareeswaran from comment #4)
> [...] One might want to make
> use of the new attributes added to the annotation (namely since() and
> forRemoval()) to add more details to the error reporting. But that can be
> taken up later as an enhancement.

this was done via bug 517326