Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2018-05-12 21:39:14 +0000
committerManoj Palat2018-05-14 06:06:55 +0000
commit2fc37aebaf1eda268e5b2770bb0b84adb58e6725 (patch)
tree28d7c396634a683602d797ada732a4ff7f0252ca
parent6b45d75b8e1ea842de31430a50aa08e7253d9df6 (diff)
downloadeclipse.jdt.core-2fc37aebaf1eda268e5b2770bb0b84adb58e6725.tar.gz
eclipse.jdt.core-2fc37aebaf1eda268e5b2770bb0b84adb58e6725.tar.xz
eclipse.jdt.core-2fc37aebaf1eda268e5b2770bb0b84adb58e6725.zip
Bug 530206 - [9] issues with terminal deprecationI20180515-0800I20180514-2000I20180514-0800
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated9Test.java2
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java2
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests9.java122
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java11
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java2
5 files changed, 133 insertions, 6 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated9Test.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated9Test.java
index 985f8536a1..2b46cee0ea 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated9Test.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated9Test.java
@@ -866,7 +866,7 @@ public class Deprecated9Test extends AbstractRegressionTest9 {
"1. WARNING in module-info.java (at line 2)\n" +
" requires jdk.xml.bind;\n" +
" ^^^^^^^^^^^^\n" +
- "The module jdk.xml.bind is deprecated since version 9\n" +
+ "The module jdk.xml.bind has been deprecated since version 9 and marked for removal\n" +
"----------\n";
runner.runWarningTest();
} finally {
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java
index 7ff1b0f054..a17703bc3e 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java
@@ -6279,7 +6279,7 @@ public class ModuleBuilderTests extends ModifyingResourceTests {
IJavaProject javaProject = createJava9Project("mod1", new String[] {"src"});
String srcMod =
- "@SuppressWarnings(\"deprecation\")\n" + // javax.xml.ws.annotation is deprecated
+ "@SuppressWarnings(\"removal\")\n" + // javax.xml.ws.annotation is deprecated for removal
"module mod1 {\n" +
" exports com.mod1.pack1;\n" +
" requires java.xml.ws.annotation;\n" +
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests9.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests9.java
index cdee72ba68..cf6c3bf7b0 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests9.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests9.java
@@ -12,6 +12,9 @@
package org.eclipse.jdt.core.tests.model;
+import java.io.IOException;
+
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IProblemRequestor;
@@ -68,7 +71,7 @@ public void setUpSuite() throws Exception {
super.setUpSuite();
// Create project with 9 compliance
- IJavaProject project9 = createJavaProject("Reconciler9", new String[] {"src"}, new String[] {"JCL9_LIB"}, "bin");
+ IJavaProject project9 = createJava9Project("Reconciler9");
createFile(
"/Reconciler9/src/module-info.java",
"/**\n" +
@@ -84,6 +87,16 @@ public void setUpSuite() throws Exception {
}
+protected void setUpWorkingCopy(String path, String contents) throws JavaModelException {
+ setUpWorkingCopy(path, contents, this.wcOwner);
+}
+private void setUpWorkingCopy(String path, String contents, WorkingCopyOwner owner) throws JavaModelException {
+ this.workingCopy.discardWorkingCopy();
+ this.workingCopy = getCompilationUnit(path).getWorkingCopy(owner, null);
+ assertEquals("Invalid problem requestor!", this.problemRequestor, this.wcOwner.getProblemRequestor(this.workingCopy));
+ setWorkingCopyContents(contents);
+ this.workingCopy.makeConsistent(null);
+}
void setWorkingCopyContents(String contents) throws JavaModelException {
this.workingCopy.getBuffer().setContents(contents);
this.problemRequestor.initialize(contents.toCharArray());
@@ -251,4 +264,111 @@ public void testCategories3() throws JavaModelException {
"mod.one[*]: {CATEGORIES}"
);
}
+public void testTerminalDeprecation1() throws CoreException {
+ try {
+ createJava9Project("P1");
+ createFolder("/P1/src/p");
+ createFile("/P1/src/p/X1.java",
+ "package p;\n" +
+ "@Deprecated(forRemoval=true)\n" +
+ "public class X1 {}");
+ createFile("/P1/src/p/X2.java",
+ "package p;\n" +
+ "public class X2 {\n" +
+ " @Deprecated(forRemoval=true)\n" +
+ " public Object field;\n" +
+ " @Deprecated(forRemoval=true)\n" +
+ " public void m() {}\n" +
+ "}\n");
+
+ setUpWorkingCopy("/P1/src/Y.java",
+ "public class Y extends p.X1 {\n" +
+ " Object foo(p.X2 x2) {\n" +
+ " x2.m();\n" +
+ " return x2.field;\n" +
+ " }\n" +
+ "}\n");
+ assertProblems(
+ "Unexpected problems",
+ "----------\n" +
+ "1. WARNING in /P1/src/Y.java (at line 1)\n" +
+ " public class Y extends p.X1 {\n" +
+ " ^^\n" +
+ "The type X1 has been deprecated and marked for removal\n" +
+ "----------\n" +
+ "2. WARNING in /P1/src/Y.java (at line 3)\n" +
+ " x2.m();\n" +
+ " ^^^\n" +
+ "The method m() from the type X2 has been deprecated and marked for removal\n" +
+ "----------\n" +
+ "3. WARNING in /P1/src/Y.java (at line 4)\n" +
+ " return x2.field;\n" +
+ " ^^^^^\n" +
+ "The field X2.field has been deprecated and marked for removal\n" +
+ "----------\n"
+ );
+ } finally {
+ deleteProject("P1");
+ }
+}
+public void testTerminalDeprecation2() throws CoreException, IOException {
+ try {
+ IJavaProject p1 = createJava9Project("P1");
+ createJar(
+ new String[] {
+ "p/X1.java",
+ "package p;\n" +
+ "@Deprecated(forRemoval=true)\n" +
+ "public class X1 {}",
+ "/P1/src/p/X2.java",
+ "package p;\n" +
+ "public class X2 {\n" +
+ " @Deprecated(forRemoval=true)\n" +
+ " public Object field;\n" +
+ " @Deprecated(forRemoval=true)\n" +
+ " public void m() {}\n" +
+ " @Deprecated public void m2() {}\n" +
+ "}\n"
+ },
+ p1.getProject().getLocation().append("lib.jar").toOSString(),
+ null,
+ "9");
+ p1.getProject().refreshLocal(2, null);
+ addLibraryEntry(p1, "/P1/lib.jar", false);
+
+ setUpWorkingCopy("/P1/src/Y.java",
+ "public class Y extends p.X1 {\n" +
+ " Object foo(p.X2 x2) {\n" +
+ " x2.m();\n" +
+ " x2.m2();\n" +
+ " return x2.field;\n" +
+ " }\n" +
+ "}\n");
+ assertProblems(
+ "Unexpected problems",
+ "----------\n" +
+ "1. WARNING in /P1/src/Y.java (at line 1)\n" +
+ " public class Y extends p.X1 {\n" +
+ " ^^\n" +
+ "The type X1 has been deprecated and marked for removal\n" +
+ "----------\n" +
+ "2. WARNING in /P1/src/Y.java (at line 3)\n" +
+ " x2.m();\n" +
+ " ^^^\n" +
+ "The method m() from the type X2 has been deprecated and marked for removal\n" +
+ "----------\n" +
+ "3. WARNING in /P1/src/Y.java (at line 4)\n" +
+ " x2.m2();\n" +
+ " ^^^^\n" +
+ "The method m2() from the type X2 is deprecated\n" +
+ "----------\n" +
+ "4. WARNING in /P1/src/Y.java (at line 5)\n" +
+ " return x2.field;\n" +
+ " ^^^^^\n" +
+ "The field X2.field has been deprecated and marked for removal\n" +
+ "----------\n");
+ } finally {
+ deleteProject("P1");
+ }
+}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java
index 1a65ef44dc..67dd0bd998 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java
@@ -389,6 +389,16 @@ private int scanElementValue(int offset) {
int tag = u1At(currentOffset);
currentOffset++;
switch (tag) {
+ case 'Z':
+ if ((this.standardAnnotationTagBits & TagBits.AnnotationDeprecated) != 0) {
+ // assume member_name is 'since', because @Deprecated has only one boolean member
+ int constantOffset = this.constantPoolOffsets[u2At(currentOffset)] - this.structOffset + 1;
+ if (i4At(constantOffset) == 1) {
+ this.standardAnnotationTagBits |= TagBits.AnnotationTerminallyDeprecated;
+ }
+ }
+ currentOffset += 2;
+ break;
case 'B':
case 'C':
case 'D':
@@ -396,7 +406,6 @@ private int scanElementValue(int offset) {
case 'I':
case 'J':
case 'S':
- case 'Z':
case 's':
case 'c':
currentOffset += 2;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
index d6d50c4047..7da599a73b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
@@ -549,14 +549,12 @@ void cachePartsFrom(IBinaryType binaryType, boolean needFieldsAndMethods) {
FieldBinding field = this.fields[i];
if (!field.isDeprecated()) {
field.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly;
- field.tagBits |= this.tagBits & TagBits.AnnotationTerminallyDeprecated;
}
}
for (int i = 0, max = this.methods.length; i < max; i++) {
MethodBinding method = this.methods[i];
if (!method.isDeprecated()) {
method.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly;
- method.tagBits |= this.tagBits & TagBits.AnnotationTerminallyDeprecated;
}
}
}

Back to the top