Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2018-05-03 13:56:05 +0000
committerStephan Herrmann2018-05-03 17:46:35 +0000
commit45b2487f8b10e6789fa58d441f9fff8a2b078983 (patch)
treea29e240e1048cc0e1d5ee98bb945bc4b984ddaac
parent5b2b497b65432ce98669eebb58329765ed9bc5f3 (diff)
downloadeclipse.jdt.core-45b2487f8b10e6789fa58d441f9fff8a2b078983.tar.gz
eclipse.jdt.core-45b2487f8b10e6789fa58d441f9fff8a2b078983.tar.xz
eclipse.jdt.core-45b2487f8b10e6789fa58d441f9fff8a2b078983.zip
Bug 515388 - [compiler][9] consider deprecation of modulesI20180504-2000I20180503-2000
- partial revert: package deprecation must not have any effect Change-Id: Ib5bbb836ebe80a4172f6ca3b1fa3de8567e1c710
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java8
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated9Test.java26
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java10
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ModuleDeclaration.java29
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SplitPackageBinding.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java23
7 files changed, 15 insertions, 89 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
index 8563f7414b..6c5dfbed37 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
@@ -1131,25 +1131,21 @@ public void test011_problem_categories() {
expectedProblemAttributes.put("UsingDeprecatedField", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
expectedProblemAttributes.put("UsingDeprecatedMethod", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
expectedProblemAttributes.put("UsingDeprecatedModule", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
- expectedProblemAttributes.put("UsingDeprecatedPackage", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
expectedProblemAttributes.put("UsingDeprecatedType", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
expectedProblemAttributes.put("UsingDeprecatedSinceVersionConstructor", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
expectedProblemAttributes.put("UsingDeprecatedSinceVersionField", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
expectedProblemAttributes.put("UsingDeprecatedSinceVersionMethod", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
expectedProblemAttributes.put("UsingDeprecatedSinceVersionModule", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
- expectedProblemAttributes.put("UsingDeprecatedSinceVersionPackage", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
expectedProblemAttributes.put("UsingDeprecatedSinceVersionType", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
expectedProblemAttributes.put("UsingTerminallyDeprecatedConstructor", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
expectedProblemAttributes.put("UsingTerminallyDeprecatedField", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
expectedProblemAttributes.put("UsingTerminallyDeprecatedMethod", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
expectedProblemAttributes.put("UsingTerminallyDeprecatedModule", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
- expectedProblemAttributes.put("UsingTerminallyDeprecatedPackage", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
expectedProblemAttributes.put("UsingTerminallyDeprecatedType", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
expectedProblemAttributes.put("UsingTerminallyDeprecatedSinceVersionConstructor", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
expectedProblemAttributes.put("UsingTerminallyDeprecatedSinceVersionField", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
expectedProblemAttributes.put("UsingTerminallyDeprecatedSinceVersionMethod", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
expectedProblemAttributes.put("UsingTerminallyDeprecatedSinceVersionModule", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
- expectedProblemAttributes.put("UsingTerminallyDeprecatedSinceVersionPackage", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
expectedProblemAttributes.put("UsingTerminallyDeprecatedSinceVersionType", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
expectedProblemAttributes.put("UsingTerminallyDeprecatedSinceVersionType", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
expectedProblemAttributes.put("VarIsNotAllowedHere", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
@@ -2049,25 +2045,21 @@ public void test012_compiler_problems_tuning() {
expectedProblemAttributes.put("UsingDeprecatedField", new ProblemAttributes(JavaCore.COMPILER_PB_DEPRECATION));
expectedProblemAttributes.put("UsingDeprecatedMethod", new ProblemAttributes(JavaCore.COMPILER_PB_DEPRECATION));
expectedProblemAttributes.put("UsingDeprecatedModule", new ProblemAttributes(JavaCore.COMPILER_PB_DEPRECATION));
- expectedProblemAttributes.put("UsingDeprecatedPackage", new ProblemAttributes(JavaCore.COMPILER_PB_DEPRECATION));
expectedProblemAttributes.put("UsingDeprecatedType", new ProblemAttributes(JavaCore.COMPILER_PB_DEPRECATION));
expectedProblemAttributes.put("UsingDeprecatedSinceVersionConstructor", new ProblemAttributes(JavaCore.COMPILER_PB_DEPRECATION));
expectedProblemAttributes.put("UsingDeprecatedSinceVersionField", new ProblemAttributes(JavaCore.COMPILER_PB_DEPRECATION));
expectedProblemAttributes.put("UsingDeprecatedSinceVersionMethod", new ProblemAttributes(JavaCore.COMPILER_PB_DEPRECATION));
expectedProblemAttributes.put("UsingDeprecatedSinceVersionModule", new ProblemAttributes(JavaCore.COMPILER_PB_DEPRECATION));
- expectedProblemAttributes.put("UsingDeprecatedSinceVersionPackage", new ProblemAttributes(JavaCore.COMPILER_PB_DEPRECATION));
expectedProblemAttributes.put("UsingDeprecatedSinceVersionType", new ProblemAttributes(JavaCore.COMPILER_PB_DEPRECATION));
expectedProblemAttributes.put("UsingTerminallyDeprecatedConstructor", new ProblemAttributes(JavaCore.COMPILER_PB_TERMINAL_DEPRECATION));
expectedProblemAttributes.put("UsingTerminallyDeprecatedField", new ProblemAttributes(JavaCore.COMPILER_PB_TERMINAL_DEPRECATION));
expectedProblemAttributes.put("UsingTerminallyDeprecatedMethod", new ProblemAttributes(JavaCore.COMPILER_PB_TERMINAL_DEPRECATION));
expectedProblemAttributes.put("UsingTerminallyDeprecatedModule", new ProblemAttributes(JavaCore.COMPILER_PB_TERMINAL_DEPRECATION));
- expectedProblemAttributes.put("UsingTerminallyDeprecatedPackage", new ProblemAttributes(JavaCore.COMPILER_PB_TERMINAL_DEPRECATION));
expectedProblemAttributes.put("UsingTerminallyDeprecatedType", new ProblemAttributes(JavaCore.COMPILER_PB_TERMINAL_DEPRECATION));
expectedProblemAttributes.put("UsingTerminallyDeprecatedSinceVersionConstructor", new ProblemAttributes(JavaCore.COMPILER_PB_TERMINAL_DEPRECATION));
expectedProblemAttributes.put("UsingTerminallyDeprecatedSinceVersionField", new ProblemAttributes(JavaCore.COMPILER_PB_TERMINAL_DEPRECATION));
expectedProblemAttributes.put("UsingTerminallyDeprecatedSinceVersionMethod", new ProblemAttributes(JavaCore.COMPILER_PB_TERMINAL_DEPRECATION));
expectedProblemAttributes.put("UsingTerminallyDeprecatedSinceVersionModule", new ProblemAttributes(JavaCore.COMPILER_PB_TERMINAL_DEPRECATION));
- expectedProblemAttributes.put("UsingTerminallyDeprecatedSinceVersionPackage", new ProblemAttributes(JavaCore.COMPILER_PB_TERMINAL_DEPRECATION));
expectedProblemAttributes.put("UsingTerminallyDeprecatedSinceVersionType", new ProblemAttributes(JavaCore.COMPILER_PB_TERMINAL_DEPRECATION));
expectedProblemAttributes.put("VarargsConflict", SKIP);
expectedProblemAttributes.put("VarargsElementTypeNotVisible", SKIP);
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 a9e0691a98..985f8536a1 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
@@ -607,7 +607,7 @@ public class Deprecated9Test extends AbstractRegressionTest9 {
"p4/package-info.java", "p4/C4.java");
Runner runner = new Runner();
runner.customOptions = new HashMap<>();
- runner.customOptions.put(JavaCore.COMPILER_PB_DEPRECATION, CompilerOptions.WARNING);
+ runner.customOptions.put(JavaCore.COMPILER_PB_DEPRECATION, CompilerOptions.ERROR);
runner.customOptions.put(JavaCore.COMPILER_PB_TERMINAL_DEPRECATION, CompilerOptions.ERROR);
runner.testFiles =
new String[] {
@@ -635,29 +635,7 @@ public class Deprecated9Test extends AbstractRegressionTest9 {
" opens p4;\n" +
"}\n"
};
- runner.expectedCompilerLog =
- "----------\n" +
- "1. WARNING in module-info.java (at line 2)\n" +
- " exports p1;\n" +
- " ^^\n" +
- "The package p1 is deprecated\n" +
- "----------\n" +
- "2. WARNING in module-info.java (at line 3)\n" +
- " exports p2;\n" +
- " ^^\n" +
- "The package p2 is deprecated since version 13\n" +
- "----------\n" +
- "3. ERROR in module-info.java (at line 4)\n" +
- " exports p3;\n" +
- " ^^\n" +
- "The package p3 has been deprecated since version 13 and marked for removal\n" +
- "----------\n" +
- "4. ERROR in module-info.java (at line 5)\n" +
- " opens p4;\n" +
- " ^^\n" +
- "The package p4 has been deprecated since version 14 and marked for removal\n" +
- "----------\n";
- runner.runNegativeTest();
+ runner.runConformTest();
}
public void testDeprecatedModule() {
Runner runner = new Runner();
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
index aae1f7c9f0..7292893682 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
@@ -1982,15 +1982,7 @@ void setSourceStart(int sourceStart);
/** @since 3.14 */
int OverridingTerminallyDeprecatedSinceVersionMethod = MethodRelated + 1414;
- // deprecation of package / module:
- /** @since 3.14 */
- int UsingDeprecatedPackage = ModuleRelated + 1425;
- /** @since 3.14 */
- int UsingDeprecatedSinceVersionPackage = ModuleRelated + 1426;
- /** @since 3.14 */
- int UsingTerminallyDeprecatedPackage = ModuleRelated + 1427;
- /** @since 3.14 */
- int UsingTerminallyDeprecatedSinceVersionPackage = ModuleRelated + 1428;
+ // deprecation of module:
/** @since 3.14 */
int UsingDeprecatedModule = ModuleRelated + 1429;
/** @since 3.14 */
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ModuleDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ModuleDeclaration.java
index b1768bf7f8..3a6ddf7e45 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ModuleDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ModuleDeclaration.java
@@ -276,29 +276,16 @@ public class ModuleDeclaration extends ASTNode implements ReferenceContext {
private void analyseReferencedPackages(CompilationUnitScope skope) {
if (this.exports != null) {
for (ExportsStatement export : this.exports) {
- PackageBinding pb = analysePackageStatement(skope, export);
- if (pb != null && !pb.hasCompilationUnit(true))
- skope.problemReporter().invalidPackageReference(IProblem.PackageDoesNotExistOrIsEmpty, export);
+ PackageBinding pb = export.resolvedPackage;
+ if (pb == null)
+ continue;
+ if (pb instanceof SplitPackageBinding)
+ pb = ((SplitPackageBinding) pb).getIncarnation(this.binding);
+ if (pb.hasCompilationUnit(true))
+ continue;
+ skope.problemReporter().invalidPackageReference(IProblem.PackageDoesNotExistOrIsEmpty, export);
}
}
- if (this.opens != null) {
- for (OpensStatement opensStat : this.opens)
- analysePackageStatement(skope, opensStat);
- // it is legal for opens to refer to a "non-existing" or empty package
- }
- }
-
- protected PackageBinding analysePackageStatement(CompilationUnitScope skope, PackageVisibilityStatement statement) {
- PackageBinding pb = statement.resolvedPackage;
- if (pb != null) {
- if (pb instanceof SplitPackageBinding)
- pb = ((SplitPackageBinding) pb).getIncarnation(this.binding);
- if (pb.isViewedAsDeprecated()) {
- TypeBinding packageInfo = pb.getType(PACKAGE_INFO_NAME, this.binding); // for annotations with details
- skope.problemReporter().deprecatedPackage(statement.pkgRef, pb, packageInfo);
- }
- }
- return pb;
}
public void analyseModuleGraph(CompilationUnitScope skope) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java
index 50e5333bb2..7c45e00a12 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -186,7 +186,7 @@ PackageBinding getPackage0Any(char[] name) {
* package with the same name.
*/
-public ReferenceBinding getType(char[] name, ModuleBinding mod) {
+ReferenceBinding getType(char[] name, ModuleBinding mod) {
ReferenceBinding referenceBinding = getType0(name);
if (referenceBinding == null) {
if ((referenceBinding = this.environment.askForType(this, name, mod)) == null) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SplitPackageBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SplitPackageBinding.java
index 4167cf8277..bc2e136889 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SplitPackageBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SplitPackageBinding.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2017, 2018 GK Software SE, and others.
+ * Copyright (c) 2017 GK Software SE, and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -239,7 +239,7 @@ public class SplitPackageBinding extends PackageBinding {
}
@Override
- public ReferenceBinding getType(char[] name, ModuleBinding mod) {
+ ReferenceBinding getType(char[] name, ModuleBinding mod) {
ReferenceBinding candidate = null;
boolean accessible = false;
for (PackageBinding incarnation : this.incarnations) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
index a319c86b4a..9150ac7bd8 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
@@ -247,14 +247,12 @@ public static int getIrritant(int problemID) {
case IProblem.UsingDeprecatedMethod :
case IProblem.UsingDeprecatedConstructor :
case IProblem.UsingDeprecatedField :
- case IProblem.UsingDeprecatedPackage :
case IProblem.UsingDeprecatedModule :
case IProblem.OverridingDeprecatedSinceVersionMethod :
case IProblem.UsingDeprecatedSinceVersionType :
case IProblem.UsingDeprecatedSinceVersionMethod :
case IProblem.UsingDeprecatedSinceVersionConstructor :
case IProblem.UsingDeprecatedSinceVersionField :
- case IProblem.UsingDeprecatedSinceVersionPackage :
case IProblem.UsingDeprecatedSinceVersionModule :
return CompilerOptions.UsingDeprecatedAPI;
@@ -263,14 +261,12 @@ public static int getIrritant(int problemID) {
case IProblem.UsingTerminallyDeprecatedMethod :
case IProblem.UsingTerminallyDeprecatedConstructor :
case IProblem.UsingTerminallyDeprecatedField :
- case IProblem.UsingTerminallyDeprecatedPackage :
case IProblem.UsingTerminallyDeprecatedModule :
case IProblem.OverridingTerminallyDeprecatedSinceVersionMethod :
case IProblem.UsingTerminallyDeprecatedSinceVersionType :
case IProblem.UsingTerminallyDeprecatedSinceVersionMethod :
case IProblem.UsingTerminallyDeprecatedSinceVersionConstructor :
case IProblem.UsingTerminallyDeprecatedSinceVersionField :
- case IProblem.UsingTerminallyDeprecatedSinceVersionPackage :
case IProblem.UsingTerminallyDeprecatedSinceVersionModule :
return CompilerOptions.UsingTerminallyDeprecatedAPI;
@@ -1850,25 +1846,6 @@ public void deprecatedType(TypeBinding type, ASTNode location, int index) {
nodeSourceEnd(null, location, index));
}
}
-public void deprecatedPackage(ImportReference pkgRef, PackageBinding resolvedPackage, TypeBinding packageInfo) {
- String sinceValue = deprecatedSinceValue(() -> packageInfo.isValidBinding() ? packageInfo.getAnnotations() : Binding.NO_ANNOTATIONS);
- boolean isTerminally = (resolvedPackage.tagBits & TagBits.AnnotationTerminallyDeprecated) != 0;
- if (sinceValue != null) {
- String[] args = { CharOperation.toString(pkgRef.tokens), sinceValue };
- handle( isTerminally ? IProblem.UsingTerminallyDeprecatedSinceVersionPackage : IProblem.UsingDeprecatedSinceVersionPackage,
- args,
- args,
- pkgRef.sourceStart,
- pkgRef.sourceEnd);
- } else {
- String[] args = { CharOperation.toString(pkgRef.tokens) };
- handle( isTerminally ? IProblem.UsingTerminallyDeprecatedPackage : IProblem.UsingDeprecatedPackage,
- args,
- args,
- pkgRef.sourceStart,
- pkgRef.sourceEnd);
- }
-}
public void deprecatedModule(ModuleReference moduleReference, ModuleBinding requiredModule) {
String sinceValue = deprecatedSinceValue(() -> requiredModule.getAnnotations());
boolean isTerminally = (requiredModule.tagBits & TagBits.AnnotationTerminallyDeprecated) != 0;

Back to the top