Skip to content

Commit b5cba2e

Browse files
authored
fobiddenapis 3.0: Remove deprecations (#161)
This will remove all deprecated items from forbiddenapis: - Ant task with old classname. - `internalRuntimeForbidden` in Ant, Gradle, Maven, CLI - the replacement is bundled signature `jdk-non-portable`. - Gradle `classesDir` property (renamed to `classesDirs` in conformance with Gradle 4+). Default on Gradle 3 is still to use the `classesDir` of underlying `SourceSet`.
1 parent 8024aee commit b5cba2e

File tree

11 files changed

+3
-182
lines changed

11 files changed

+3
-182
lines changed

src/main/java/de/thetaphi/forbiddenapis/AntTask.java

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/main/java/de/thetaphi/forbiddenapis/Constants.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
package de.thetaphi.forbiddenapis;
2020

21-
import java.util.Locale;
2221
import java.util.regex.Pattern;
2322

2423
import org.objectweb.asm.Type;
@@ -29,9 +28,6 @@ public interface Constants {
2928

3029
final Pattern JDK_SIG_PATTERN = Pattern.compile("(jdk\\-.*?\\-)(\\d+)(\\.\\d+)?(\\.\\d+)*");
3130

32-
final String DEPRECATED_WARN_INTERNALRUNTIME = String.format(Locale.ENGLISH,
33-
"The setting 'internalRuntimeForbidden' was deprecated and will be removed in next version. For backwards compatibility task/mojo is using '%s' bundled signatures instead.", BS_JDK_NONPORTABLE);
34-
3531
final Type DEPRECATED_TYPE = Type.getType(Deprecated.class);
3632
final String DEPRECATED_DESCRIPTOR = DEPRECATED_TYPE.getDescriptor();
3733

src/main/java/de/thetaphi/forbiddenapis/ant/AntTask.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ public class AntTask extends Task implements Constants {
6464
private Path classpath = null;
6565

6666
private boolean failOnUnsupportedJava = false;
67-
@Deprecated private boolean internalRuntimeForbidden = false;
6867
private boolean restrictClassFilename = true;
6968
private boolean failOnMissingClasses = true;
7069
private boolean failOnUnresolvableSignatures = true;
@@ -149,10 +148,6 @@ public void info(String msg) {
149148
}
150149
checker.addBundledSignatures(name, targetVersion);
151150
}
152-
if (internalRuntimeForbidden) {
153-
log.warn(DEPRECATED_WARN_INTERNALRUNTIME);
154-
checker.addBundledSignatures(BS_JDK_NONPORTABLE, null);
155-
}
156151

157152
@SuppressWarnings("unchecked")
158153
final Iterator<Resource> iter = apiSignatures.iterator();
@@ -338,17 +333,6 @@ public void setFailOnUnresolvableSignatures(boolean failOnUnresolvableSignatures
338333
this.failOnUnresolvableSignatures = failOnUnresolvableSignatures;
339334
}
340335

341-
/**
342-
* Forbids calls to non-portable runtime APIs (like {@code sun.misc.Unsafe}).
343-
* <em>Please note:</em> This enables {@code "jdk-non-portable"} bundled signatures for backwards compatibility.
344-
* Defaults to {@code false}.
345-
* @deprecated Use bundled signatures {@code "jdk-non-portable"} or {@code "jdk-internal"} instead.
346-
*/
347-
@Deprecated
348-
public void setInternalRuntimeForbidden(boolean internalRuntimeForbidden) {
349-
this.internalRuntimeForbidden = internalRuntimeForbidden;
350-
}
351-
352336
/** Automatically restrict resource names included to files with a name ending in '.class'.
353337
* This makes filesets easier, as the includes="**&#47;*.class" is not needed.
354338
* Defaults to {@code true}.

src/main/java/de/thetaphi/forbiddenapis/cli/CliMain.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
public final class CliMain implements Constants {
5454

5555
private final Option classpathOpt, dirOpt, includesOpt, excludesOpt, signaturesfileOpt, bundledsignaturesOpt, suppressannotationsOpt,
56-
internalruntimeforbiddenOpt, allowmissingclassesOpt, allowunresolvablesignaturesOpt, versionOpt, helpOpt;
56+
allowmissingclassesOpt, allowunresolvablesignaturesOpt, versionOpt, helpOpt;
5757
private final CommandLine cmd;
5858

5959
private static final Logger LOG = StdIoLogger.INSTANCE;
@@ -125,10 +125,6 @@ public CliMain(String... args) throws ExitException {
125125
.valueSeparator(',')
126126
.argName("classname")
127127
.build());
128-
options.addOption(internalruntimeforbiddenOpt = Option.builder()
129-
.desc(String.format(Locale.ENGLISH, "DEPRECATED: forbids calls to non-portable runtime APIs; use bundled signatures '%s' instead", BS_JDK_NONPORTABLE))
130-
.longOpt("internalruntimeforbidden")
131-
.build());
132128
options.addOption(allowmissingclassesOpt = Option.builder()
133129
.desc("don't fail if a referenced class is missing on classpath")
134130
.longOpt("allowmissingclasses")
@@ -258,10 +254,6 @@ public void run() throws ExitException {
258254
if (bundledSignatures != null) for (String bs : new LinkedHashSet<>(Arrays.asList(bundledSignatures))) {
259255
checker.addBundledSignatures(bs, null);
260256
}
261-
if (cmd.hasOption(internalruntimeforbiddenOpt.getLongOpt())) {
262-
LOG.warn(DEPRECATED_WARN_INTERNALRUNTIME);
263-
checker.addBundledSignatures(BS_JDK_NONPORTABLE, null);
264-
}
265257

266258
final String[] signaturesFiles = cmd.getOptionValues(signaturesfileOpt.getLongOpt());
267259
if (signaturesFiles != null) for (String sf : new LinkedHashSet<>(Arrays.asList(signaturesFiles))) {

src/main/java/de/thetaphi/forbiddenapis/gradle/CheckForbiddenApis.java

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -133,32 +133,6 @@ public void setClassesDirs(FileCollection classesDirs) {
133133
this.classesDirs = classesDirs;
134134
}
135135

136-
/**
137-
* Directory with the class files to check.
138-
* Defaults to current sourseSet's output directory (Gradle 3 only).
139-
* @deprecated use {@link #getClassesDirs()} instead. If there are more than one
140-
* {@code classesDir} set by {@link #setClassesDirs(FileCollection)}, this getter may
141-
* throw an exception!
142-
*/
143-
@Deprecated
144-
@Internal
145-
public File getClassesDir() {
146-
final FileCollection col = getClassesDirs();
147-
return (col == null) ? null : col.getSingleFile();
148-
}
149-
150-
/** Sets the directory where to look for classes. Overwrites any value set by {@link #setClassesDirs(FileCollection)}!
151-
* @deprecated use {@link #setClassesDirs(FileCollection)} instead.
152-
* @see #getClassesDir
153-
*/
154-
@Deprecated
155-
public void setClassesDir(File classesDir) {
156-
if (classesDir == null) throw new NullPointerException("classesDir");
157-
getLogger().warn("The 'classesDir' property on the '{}' task is deprecated. Use 'classesDirs' of type FileCollection instead!",
158-
getName());
159-
setClassesDirs(getProject().files(classesDir));
160-
}
161-
162136
/** Returns the pattern set to match against class files in {@link #getClassesDir()}. */
163137
@Internal
164138
public PatternSet getPatternSet() {
@@ -252,26 +226,6 @@ public void setBundledSignatures(Set<String> bundledSignatures) {
252226
data.bundledSignatures = bundledSignatures;
253227
}
254228

255-
/**
256-
* Forbids calls to non-portable runtime APIs (like {@code sun.misc.Unsafe}).
257-
* <em>Please note:</em> This enables {@code "jdk-non-portable"} bundled signatures for backwards compatibility.
258-
* Defaults to {@code false}.
259-
* @deprecated Use <a href="bundled-signatures.html">bundled signatures</a> {@code "jdk-non-portable"} or {@code "jdk-internal"} instead.
260-
*/
261-
@Deprecated
262-
@Input
263-
public boolean getInternalRuntimeForbidden() {
264-
return data.internalRuntimeForbidden;
265-
}
266-
267-
/** @see #getInternalRuntimeForbidden
268-
* @deprecated Use bundled signatures {@code "jdk-non-portable"} or {@code "jdk-internal"} instead.
269-
*/
270-
@Deprecated
271-
public void setInternalRuntimeForbidden(boolean internalRuntimeForbidden) {
272-
data.internalRuntimeForbidden = internalRuntimeForbidden;
273-
}
274-
275229
/**
276230
* Fail the build, if the bundled ASM library cannot read the class file format
277231
* of the runtime library or the runtime library cannot be discovered.
@@ -575,10 +529,6 @@ public void info(String msg) {
575529
checker.addBundledSignatures(bs, bundledSigsJavaVersion);
576530
}
577531
}
578-
if (getInternalRuntimeForbidden()) {
579-
log.warn(DEPRECATED_WARN_INTERNALRUNTIME);
580-
checker.addBundledSignatures(BS_JDK_NONPORTABLE, null);
581-
}
582532

583533
final FileCollection signaturesFiles = getSignaturesFiles();
584534
if (signaturesFiles != null) for (final File f : signaturesFiles) {

src/main/java/de/thetaphi/forbiddenapis/gradle/CheckForbiddenApisExtension.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public class CheckForbiddenApisExtension {
3737
public List<String> signatures = new ArrayList<>();
3838
public Set<String> bundledSignatures = new LinkedHashSet<>(),
3939
suppressAnnotations = new LinkedHashSet<>();
40-
@Deprecated public boolean internalRuntimeForbidden = false;
4140
public boolean failOnUnsupportedJava = false,
4241
failOnMissingClasses = true,
4342
failOnUnresolvableSignatures = true,

src/main/java/de/thetaphi/forbiddenapis/maven/AbstractCheckMojo.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,6 @@ public abstract class AbstractCheckMojo extends AbstractMojo implements Constant
111111
@Parameter(required = false)
112112
private String[] bundledSignatures;
113113

114-
/**
115-
* Forbids calls to non-portable runtime APIs (like {@code sun.misc.Unsafe}).
116-
* <em>Please note:</em> This enables {@code "jdk-non-portable"} bundled signatures for backwards compatibility.
117-
* @deprecated Use <a href="bundled-signatures.html">bundled signatures</a> {@code "jdk-non-portable"} or {@code "jdk-internal"} instead.
118-
* @since 1.0
119-
*/
120-
@Deprecated
121-
@Parameter(required = false, defaultValue = "false")
122-
private boolean internalRuntimeForbidden;
123-
124114
/**
125115
* Fail the build, if the bundled ASM library cannot read the class file format
126116
* of the runtime library or the runtime library cannot be discovered.
@@ -377,10 +367,6 @@ public void info(String msg) {
377367
checker.addBundledSignatures(bs, targetVersion);
378368
}
379369
}
380-
if (internalRuntimeForbidden) {
381-
log.warn(DEPRECATED_WARN_INTERNALRUNTIME);
382-
checker.addBundledSignatures(BS_JDK_NONPORTABLE, null);
383-
}
384370

385371
final Set<File> sigFiles = new LinkedHashSet<>();
386372
final Set<URL> sigUrls = new LinkedHashSet<>();

src/test/antunit/TestCli.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,17 @@
4242
<arg value="-b"/>
4343
<arg value="jdk-unsafe-${jdk.version},jdk-deprecated-${jdk.version}"/>
4444
<arg value="--bundledsignatures"/>
45-
<arg value="jdk-system-out"/>
45+
<arg value="jdk-system-out,jdk-non-portable"/>
4646
<arg value="--includes"/>
4747
<arg value="Java7*.class"/>
4848
<arg value="--excludes"/>
4949
<arg value="Java7ClassReferences.class"/>
50-
<arg value="--internalruntimeforbidden"/>
5150
</java>
5251
<au:assertLogContains text=" 0 error(s)."/>
5352
<au:assertLogContains text="Reading bundled API signatures: jdk-deprecated-${jdk.version}"/>
5453
<au:assertLogContains text="Reading bundled API signatures: jdk-unsafe-${jdk.version}"/>
5554
<au:assertLogContains text="Reading bundled API signatures: jdk-system-out"/>
5655
<au:assertLogContains text="Reading bundled API signatures: jdk-non-portable"/>
57-
<au:assertLogContains text="WARNING: The setting 'internalRuntimeForbidden' was deprecated"/>
5856
</target>
5957

6058
<target name="testSuppressAnnotations">

src/test/antunit/TestDeprecatedTask.xml

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/test/antunit/TestInternalRuntimeCalls.xml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,6 @@
3131
<au:assertLogContains level="error" text=" 2 error(s)"/>
3232
</target>
3333

34-
<target name="testDeprecatedInternalRuntimeForbidden" if="has.sunmisc">
35-
<au:expectfailure expectedMessage="Check for forbidden API calls failed, see log">
36-
<forbiddenapis internalRuntimeForbidden="true" failOnMissingClasses="false">
37-
<file file="OracleInternalRuntime.class"/>
38-
</forbiddenapis>
39-
</au:expectfailure>
40-
<au:assertLogContains level="warn" text="The setting 'internalRuntimeForbidden' was deprecated"/>
41-
<au:assertLogContains level="error" text="sun.misc.BASE64Encoder [non-portable or internal runtime class]"/>
42-
<au:assertLogContains level="error" text=" 2 error(s)"/>
43-
</target>
44-
4534
<!-- this should work also with non-Oracle runtimes, as no heuristics: -->
4635
<target name="testInternalSignatures">
4736
<au:expectfailure expectedMessage="Check for forbidden API calls failed, see log">

0 commit comments

Comments
 (0)