Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 121392 Details for
Bug 258906
[jsr269] Package annotations not visible to Java 6 APT processors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Revised patch with test
patch.txt (text/plain), 8.01 KB, created by
Srikanth Sankaran
on 2008-12-31 08:53:08 EST
(
hide
)
Description:
Revised patch with test
Filename:
MIME Type:
Creator:
Srikanth Sankaran
Created:
2008-12-31 08:53:08 EST
Size:
8.01 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java,v >retrieving revision 1.65 >diff -u -r1.65 Annotation.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java 5 Sep 2008 10:24:43 -0000 1.65 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java 31 Dec 2008 12:13:41 -0000 >@@ -378,6 +378,15 @@ > break checkTargetCompatibility; > } else if ((metaTagBits & TagBits.AnnotationForType) != 0) > break checkTargetCompatibility; >+ else { >+ // Annotations that target a package are kosher for the synthetic interface type >+ // package-info. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=258906 >+ char [] name = ((ReferenceBinding)this.recipient).sourceName(); >+ if (name != null && CharOperation.equals(name, TypeConstants.PACKAGE_INFO_NAME)) { >+ if ((metaTagBits & TagBits.AnnotationForPackage) != 0) >+ break checkTargetCompatibility; >+ } >+ } > break; > case Binding.METHOD : > if (((MethodBinding)this.recipient).isConstructor()) { >Index: compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java,v >retrieving revision 1.397 >diff -u -r1.397 Parser.java >--- compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 5 Dec 2008 15:57:56 -0000 1.397 >+++ compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 31 Dec 2008 12:14:00 -0000 >@@ -2837,6 +2837,10 @@ > declaration.modifiers = ClassFileConstants.AccDefault | ClassFileConstants.AccInterface; > this.compilationUnit.types[0] = declaration; > declaration.javadoc = this.compilationUnit.javadoc; >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=258906 >+ if (this.compilationUnit.currentPackage != null) { >+ declaration.annotations = this.compilationUnit.currentPackage.annotations; >+ } > } > } > protected void consumeEmptyMemberValueArrayInitializer() { >@@ -4046,6 +4050,10 @@ > declaration.modifiers = ClassFileConstants.AccDefault | ClassFileConstants.AccInterface; > this.compilationUnit.types[0] = declaration; > declaration.javadoc = this.compilationUnit.javadoc; >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=258906 >+ if (this.compilationUnit.currentPackage != null) { >+ declaration.annotations = this.compilationUnit.currentPackage.annotations; >+ } > } > } > protected void consumeInternalCompilationUnitWithTypes() { >@@ -4066,6 +4074,10 @@ > declaration.modifiers = ClassFileConstants.AccDefault | ClassFileConstants.AccInterface; > this.compilationUnit.types[0] = declaration; > declaration.javadoc = this.compilationUnit.javadoc; >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=258906 >+ if (this.compilationUnit.currentPackage != null) { >+ declaration.annotations = this.compilationUnit.currentPackage.annotations; >+ } > } else { > this.compilationUnit.types = new TypeDeclaration[length]; > this.astPtr -= length; >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java,v >retrieving revision 1.190 >diff -u -r1.190 AnnotationTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 25 Nov 2008 09:57:46 -0000 1.190 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 31 Dec 2008 12:14:14 -0000 >@@ -14,18 +14,29 @@ > import java.io.IOException; > import java.util.HashMap; > import java.util.Hashtable; >+import java.util.Locale; > import java.util.Map; > > import junit.framework.Test; > > import org.eclipse.jdt.core.ToolFactory; >+import org.eclipse.jdt.core.tests.util.Util; > import org.eclipse.jdt.core.util.ClassFileBytesDisassembler; >+import org.eclipse.jdt.internal.compiler.Compiler; >+import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy; >+import org.eclipse.jdt.internal.compiler.IProblemFactory; > import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; >+import org.eclipse.jdt.internal.compiler.batch.CompilationUnit; >+import org.eclipse.jdt.internal.compiler.batch.FileSystem; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException; >+import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; >+import org.eclipse.jdt.internal.compiler.env.INameEnvironment; > import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; >-import org.eclipse.jdt.core.tests.util.Util; >+import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding; >+import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; >+import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; > > public class AnnotationTest extends AbstractComparableTest { > >@@ -70,6 +81,78 @@ > this.reportMissingJavadocComments = null; > } > >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=258906 >+ public void testPackageAnnotations() { >+ >+ Map options = getCompilerOptions(); >+ options.put(CompilerOptions.OPTION_Process_Annotations, CompilerOptions.ENABLED); >+ >+ IProblemFactory problemFactory = new DefaultProblemFactory(Locale.getDefault()); >+ Requestor requestor = >+ new Requestor( >+ false, >+ null /*no custom requestor*/, >+ false, /* show category */ >+ false /* show warning token*/); >+ >+ requestor.outputPath = "bin/"; >+ >+ String[] classpath = Util.getJavaClassLibs(); >+ >+ INameEnvironment nameEnvironment = new FileSystem(classpath, new String[] {}, null); >+ IErrorHandlingPolicy errorHandlingPolicy = >+ new IErrorHandlingPolicy() { >+ public boolean proceedOnErrors() { >+ return true; >+ } >+ public boolean stopOnFirstError() { >+ return false; >+ } >+ }; >+ >+ CompilerOptions compilerOptions = new CompilerOptions(options); >+ compilerOptions.performMethodsFullRecovery = false; >+ compilerOptions.performStatementsRecovery = false; >+ Compiler compiler = >+ new Compiler( >+ nameEnvironment, >+ errorHandlingPolicy, >+ compilerOptions, >+ requestor, >+ problemFactory); >+ compiler.options.produceReferenceInfo = true; >+ >+ String code = "@javax.xml.bind.annotation.XmlSchema(namespace = \"test\")\npackage testpack;\n"; >+ ICompilationUnit source = new CompilationUnit(code.toCharArray(), "testpack/package-info.java", null); >+ >+ // don't call compile as would be normally expected since that wipes out the lookup environment >+ // before we could query it. Use internal API resolve instead which can run a subset of the >+ // compilation steps for us. >+ >+ compiler.resolve (source, >+ true, // verifyMethods, >+ true, // boolean analyzeCode, >+ false // generateCode >+ ); >+ char [][] compoundName = new char [][] { "testpack".toCharArray(), "package-info".toCharArray()}; >+ ReferenceBinding type = compiler.lookupEnvironment.getType(compoundName); >+ AnnotationBinding[] annotations = null; >+ if (type != null && type.isValidBinding()) { >+ annotations = type.getAnnotations(); >+ } >+ assertTrue ("Annotations missing on package-info interface", >+ annotations != null && annotations.length == 1); >+ String actual = annotations[0].toString(); >+ >+ assertEquals("Wrong annotation on package-info interface ", >+ "@XmlSchema{ namespace = (String)\"test\"}", >+ actual); >+ nameEnvironment.cleanup(); >+ if (requestor.hasErrors) >+ System.err.print(requestor.problemLog); // problem log empty if no problems >+ compiler = null; >+ } >+ > public void test001() { > this.runConformTest( > new String[] {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 258906
:
120549
|
120550
|
120937
|
121339
|
121392
|
121550
|
121822