Skip to content

Commit

Permalink
Add support for Jigsaw and new Java version numbering (a hack for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
uschindler committed Mar 7, 2016
1 parent fc77a31 commit 7606b02
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
14 changes: 9 additions & 5 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
- To define a target to be only run on a specific version, add <equals/> condition to one of the supplied versions.
- To explicitely exclude specific versions (and unknown ones), add a condition to disallow "unknown" and some versions like "1.9"!
-->
<condition property="build.java.runtime" value="1.9">
<equals arg1="${-cleaned.specification.version}" arg2="9"/>
</condition>
<condition property="build.java.runtime" value="${-cleaned.specification.version}" else="unknown">
<or>
<equals arg1="${-cleaned.specification.version}" arg2="1.6"/>
Expand All @@ -66,11 +69,12 @@
<!-- workaround for https://issues.apache.org/bugzilla/show_bug.cgi?id=53347 -->
<condition property="build.compiler" value="javac1.7">
<and>
<or>
<equals arg1="${build.java.runtime}" arg2="1.9"/>
<equals arg1="${build.java.runtime}" arg2="1.8"/>
<equals arg1="${build.java.runtime}" arg2="unknown"/>
</or>
<not>
<or>
<equals arg1="${build.java.runtime}" arg2="1.6"/>
<equals arg1="${build.java.runtime}" arg2="1.7"/>
</or>
</not>
<or>
<antversion exactly="1.8.3" />
<antversion exactly="1.8.4" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
# It is provided here for reference, but can easily regenerated by executing from the source folder of forbidden-apis:
# $ ant generate-deprecated

# This file contains all public, deprecated API signatures in Java version 1.9 (extracted from build 1.9.0-ea).
# This file contains all public, deprecated API signatures in Java version 1.9 (extracted from build 9-ea).

@ignoreUnresolvable
@defaultMessage Deprecated in Java 1.9

java.awt.AWTKeyStroke#registerSubclass(java.lang.Class)
java.awt.BorderLayout#addLayoutComponent(java.lang.String,java.awt.Component)
java.awt.CardLayout#addLayoutComponent(java.lang.String,java.awt.Component)
java.awt.CheckboxGroup#getCurrent()
Expand Down Expand Up @@ -148,6 +149,8 @@ java.lang.Character#isJavaLetterOrDigit(char)
java.lang.Character#isSpace(char)
java.lang.Character$UnicodeBlock#SURROGATES_AREA
java.lang.ClassLoader#defineClass(byte[],int,int)
java.lang.ClassLoader#getPackage(java.lang.String)
java.lang.Package#getPackage(java.lang.String)
java.lang.Runtime#getLocalizedInputStream(java.io.InputStream)
java.lang.Runtime#getLocalizedOutputStream(java.io.OutputStream)
java.lang.Runtime#runFinalizersOnExit(boolean)
Expand Down Expand Up @@ -178,6 +181,7 @@ java.lang.ThreadGroup#allowThreadSuspension(boolean)
java.lang.ThreadGroup#resume()
java.lang.ThreadGroup#stop()
java.lang.ThreadGroup#suspend()
java.lang.reflect.Proxy#getProxyClass(java.lang.ClassLoader,java.lang.Class[])
java.net.DatagramSocketImpl#getTTL()
java.net.DatagramSocketImpl#setTTL(byte)
java.net.HttpURLConnection#HTTP_SERVER_ERROR
Expand Down Expand Up @@ -279,7 +283,6 @@ java.util.Properties#save(java.io.OutputStream,java.lang.String)
java.util.jar.Attributes$Name#EXTENSION_INSTALLATION
java.util.jar.Attributes$Name#IMPLEMENTATION_URL
java.util.jar.Attributes$Name#IMPLEMENTATION_VENDOR_ID
java.util.logging.LogRecord#getMillis()
java.util.logging.LogRecord#setMillis(long)
java.util.logging.Logger#global
java.util.logging.Logger#logrb(java.util.logging.Level,java.lang.String,java.lang.String,java.lang.String,java.lang.String)
Expand Down Expand Up @@ -336,6 +339,7 @@ javax.management.monitor.StringMonitor#getDerivedGaugeTimeStamp()
javax.management.monitor.StringMonitorMBean#getDerivedGauge()
javax.management.monitor.StringMonitorMBean#getDerivedGaugeTimeStamp()
javax.management.openmbean.OpenType#ALLOWED_CLASSNAMES
javax.management.remote.rmi.RMIIIOPServerImpl
javax.naming.Context#APPLET
javax.net.ssl.HandshakeCompletedEvent#getPeerCertificateChain()
javax.net.ssl.SSLSession#getPeerCertificateChain()
Expand Down
8 changes: 6 additions & 2 deletions src/tools/groovy/generate-deprecated.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@
import org.apache.tools.ant.BuildException;

URL objectClassURL = ClassLoader.getSystemClassLoader().getResource("java/lang/Object.class");
boolean isJava9 = objectClassURL != null && "jrt".equalsIgnoreCase(objectClassURL.getProtocol());
boolean isJava9 = Class.metaClass.respondsTo(Class.class, 'getModule') ||
(objectClassURL != null && "jrt".equalsIgnoreCase(objectClassURL.getProtocol()));

boolean hasRTJar = new File(properties['java.home'], "lib/rt.jar").isFile();

String vendor = properties['java.vendor'].toLowerCase(Locale.ENGLISH);
String vendor = properties['java.vendor'].toLowerCase(Locale.ROOT);
boolean isOracle = vendor.contains("oracle") || vendor.contains("sun microsystems");
boolean isDetectedJavaVersion = properties['java.version'].startsWith(properties['build.java.runtime']);
if (!isDetectedJavaVersion) {
isDetectedJavaVersion = properties['java.version'].startsWith('9') && properties['build.java.runtime'] == '1.9';
}

if (isOracle && isDetectedJavaVersion && (isJava9 || hasRTJar)) {
String script = isJava9 ? "generate-deprecated-java9.groovy" : "generate-deprecated-java6.groovy";
Expand Down
2 changes: 0 additions & 2 deletions src/tools/java/de/thetaphi/forbiddenapis/DeprecatedGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ public DeprecatedGen(String javaVersion, Input source, File output) {
this.javaVersion = javaVersion;
this.source = source;
this.output = output;
if (!System.getProperty("java.version").startsWith(javaVersion))
throw new IllegalArgumentException("Java version mismatch: build " + System.getProperty("java.version") + " != expected " + javaVersion);
this.header = new StringBuilder()
.append("# This file contains API signatures extracted from the rt.jar / jimage file shipped with the class library of Oracle's Java Runtime Environment.").append(NL)
.append("# It is provided here for reference, but can easily regenerated by executing from the source folder of forbidden-apis:").append(NL)
Expand Down

0 comments on commit 7606b02

Please sign in to comment.