From 7f8fc49431c33413ee60162aa259f3ac8b637be5 Mon Sep 17 00:00:00 2001 From: Brett Randall Date: Fri, 20 Oct 2017 14:24:16 +1100 Subject: [PATCH 1/6] Use openjdk7 instead of oraclejdk7 in Travis. Ref https://github.com/travis-ci/travis-ci/issues/7019 . --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9a8769e82..f46e797dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: groovy jdk: - - oraclejdk7 + - openjdk7 - oraclejdk8 before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock From 300c5a82d0b5db14fec08be7912b101f14a59b4b Mon Sep 17 00:00:00 2001 From: Brett Randall Date: Tue, 20 Feb 2018 12:02:48 +1100 Subject: [PATCH 2/6] Added BouncyCastle openjdk7 crypto workaround. Ref: https://github.com/travis-ci/travis-ci/issues/8503#issuecomment-339943812 --- .travis.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f46e797dd..a3d5400a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,14 @@ cache: - $HOME/.gradle/caches - $HOME/.gradle/wrapper before_install: - chmod +x gradlew + - chmod +x gradlew + - sudo apt-get -qq update + - sudo apt-get install -y zip curl locate libbcprov-java + - | + sudo ln -s /usr/share/java/bcprov.jar /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/bcprov.jar \ + && sudo awk -F . -v OFS=. 'BEGIN{n=2}/^security\.provider/ {split($3, posAndEquals, "=");$3=n++"="posAndEquals[2];print;next} 1' /etc/java-7-openjdk/security/java.security > /tmp/java.security \ + && sudo echo "security.provider.1=org.bouncycastle.jce.provider.BouncyCastleProvider" >> /tmp/java.security \ + && sudo mv /tmp/java.security /etc/java-7-openjdk/security/java.security before_script: - "export DISPLAY=:99.0" - "sh -e /etc/init.d/xvfb start" From d1c0ea7204bdef19d535d01e5753519032d00420 Mon Sep 17 00:00:00 2001 From: Brett Randall Date: Tue, 20 Feb 2018 13:24:53 +1100 Subject: [PATCH 3/6] Travis: added oraclejdk9. Progress towards JDK9 #390. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a3d5400a9..c5ec2473c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ language: groovy jdk: - openjdk7 - oraclejdk8 + - oraclejdk9 before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock cache: From b31ec47a83dd5d0ffcbaa2b00892b31f53888089 Mon Sep 17 00:00:00 2001 From: Brett Randall Date: Tue, 20 Feb 2018 13:32:16 +1100 Subject: [PATCH 4/6] Upgraded to Gradle 4.5.1 to allow building on JDK9. Progress towards JDK9 #390. --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 85a79beaa..104c7f590 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-bin.zip From fc26b614dacf328ef0d9dd81ac4343a754c5b60c Mon Sep 17 00:00:00 2001 From: Brett Randall Date: Tue, 20 Feb 2018 13:52:12 +1100 Subject: [PATCH 5/6] Bumped Groovy version to 2.4.13. Minimum for Groovy on JDK9 is 2.4.12, ref https://github.com/gradle/gradle/issues/2995 . Progress towards JDK9 #390. --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 86a504e86..c71c85f14 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,7 +21,7 @@ tomcat7_servlet_api_version=3.0.1 tomcat8_version=8.0.44 tomcat8_servlet_api_version=3.1.0 asm_version=5.0.3 -groovy_version=2.4.11 +groovy_version=2.4.13 spock_version=1.1-groovy-2.4 logback_version=1.1.3 slf4j_version=1.7.12 From 0a2cf46158197f637e9b666a0a64938c211e0231 Mon Sep 17 00:00:00 2001 From: Brett Randall Date: Tue, 20 Feb 2018 18:18:43 +1100 Subject: [PATCH 6/6] JDK9 compatability: removed uses of JDK-internal sun.misc.* API. Progress towards JDK9 #390. --- .../akhikhl/gretty/FilteringClassLoader.java | 47 +++++++++--------- .../akhikhl/gretty/FilteringClassLoader.java | 47 +++++++++--------- .../akhikhl/gretty/FilteringClassLoader.java | 47 +++++++++--------- .../akhikhl/gretty/FilteringClassLoader.java | 47 +++++++++--------- .../akhikhl/gretty/FilteringClassLoader.java | 47 +++++++++--------- .../akhikhl/gretty/FilteringClassLoader.java | 48 ++++++++----------- 6 files changed, 130 insertions(+), 153 deletions(-) diff --git a/libs/gretty-runner-jetty7/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java b/libs/gretty-runner-jetty7/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java index df495dcf2..7d97d21d1 100644 --- a/libs/gretty-runner-jetty7/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java +++ b/libs/gretty-runner-jetty7/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java @@ -9,14 +9,11 @@ package org.akhikhl.gretty; import org.eclipse.jetty.webapp.WebAppClassLoader; -import sun.misc.CompoundEnumeration; -import sun.misc.Resource; -import sun.misc.URLClassPath; import java.io.IOException; import java.net.URL; -import java.net.URLClassLoader; import java.util.ArrayList; +import java.util.Collections; import java.util.Enumeration; import java.util.List; @@ -31,12 +28,25 @@ public class FilteringClassLoader extends WebAppClassLoader { private final List serverResources = new ArrayList(); + private ClassLoader bootClassLoader; + public FilteringClassLoader(Context context) throws IOException { super(context); + findBootClassLoader(); } public FilteringClassLoader(ClassLoader parent, Context context) throws IOException { super(parent, context); + findBootClassLoader(); + } + + protected void findBootClassLoader() { + bootClassLoader = getParent(); + if (bootClassLoader != null) { + while(bootClassLoader.getParent() != null) { + bootClassLoader = bootClassLoader.getParent(); + } + } } public void addServerClass(String serverClass) { @@ -64,31 +74,18 @@ protected Class loadClass(String name, boolean resolve) throws ClassNotFoundE @Override public Enumeration getResources(String name) throws IOException { - for(String serverResource : serverResources) + for(String serverResource : serverResources) { if(name.startsWith(serverResource)) { - Enumeration[] tmp = (Enumeration[]) new Enumeration[2]; - tmp[0] = getBootstrapResources(name); - tmp[1] = findResources(name); - return new CompoundEnumeration(tmp); + final List resources = new ArrayList<>(); + resources.addAll(Collections.list(getBootstrapResources(name))); + resources.addAll(Collections.list(findResources(name))); + return Collections.enumeration(resources); } + } return super.getResources(name); } - private static Enumeration getBootstrapResources(String name) throws IOException { - final Enumeration e = - getBootstrapClassPath().getResources(name); - return new Enumeration () { - public URL nextElement() { - return e.nextElement().getURL(); - } - public boolean hasMoreElements() { - return e.hasMoreElements(); - } - }; - } - - // Returns the URLClassPath that is used for finding system resources. - static URLClassPath getBootstrapClassPath() { - return sun.misc.Launcher.getBootstrapClassPath(); + private Enumeration getBootstrapResources(String name) throws IOException { + return bootClassLoader.getResources(name); } } diff --git a/libs/gretty-runner-jetty8/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java b/libs/gretty-runner-jetty8/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java index df495dcf2..7d97d21d1 100644 --- a/libs/gretty-runner-jetty8/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java +++ b/libs/gretty-runner-jetty8/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java @@ -9,14 +9,11 @@ package org.akhikhl.gretty; import org.eclipse.jetty.webapp.WebAppClassLoader; -import sun.misc.CompoundEnumeration; -import sun.misc.Resource; -import sun.misc.URLClassPath; import java.io.IOException; import java.net.URL; -import java.net.URLClassLoader; import java.util.ArrayList; +import java.util.Collections; import java.util.Enumeration; import java.util.List; @@ -31,12 +28,25 @@ public class FilteringClassLoader extends WebAppClassLoader { private final List serverResources = new ArrayList(); + private ClassLoader bootClassLoader; + public FilteringClassLoader(Context context) throws IOException { super(context); + findBootClassLoader(); } public FilteringClassLoader(ClassLoader parent, Context context) throws IOException { super(parent, context); + findBootClassLoader(); + } + + protected void findBootClassLoader() { + bootClassLoader = getParent(); + if (bootClassLoader != null) { + while(bootClassLoader.getParent() != null) { + bootClassLoader = bootClassLoader.getParent(); + } + } } public void addServerClass(String serverClass) { @@ -64,31 +74,18 @@ protected Class loadClass(String name, boolean resolve) throws ClassNotFoundE @Override public Enumeration getResources(String name) throws IOException { - for(String serverResource : serverResources) + for(String serverResource : serverResources) { if(name.startsWith(serverResource)) { - Enumeration[] tmp = (Enumeration[]) new Enumeration[2]; - tmp[0] = getBootstrapResources(name); - tmp[1] = findResources(name); - return new CompoundEnumeration(tmp); + final List resources = new ArrayList<>(); + resources.addAll(Collections.list(getBootstrapResources(name))); + resources.addAll(Collections.list(findResources(name))); + return Collections.enumeration(resources); } + } return super.getResources(name); } - private static Enumeration getBootstrapResources(String name) throws IOException { - final Enumeration e = - getBootstrapClassPath().getResources(name); - return new Enumeration () { - public URL nextElement() { - return e.nextElement().getURL(); - } - public boolean hasMoreElements() { - return e.hasMoreElements(); - } - }; - } - - // Returns the URLClassPath that is used for finding system resources. - static URLClassPath getBootstrapClassPath() { - return sun.misc.Launcher.getBootstrapClassPath(); + private Enumeration getBootstrapResources(String name) throws IOException { + return bootClassLoader.getResources(name); } } diff --git a/libs/gretty-runner-jetty9/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java b/libs/gretty-runner-jetty9/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java index df495dcf2..7d97d21d1 100644 --- a/libs/gretty-runner-jetty9/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java +++ b/libs/gretty-runner-jetty9/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java @@ -9,14 +9,11 @@ package org.akhikhl.gretty; import org.eclipse.jetty.webapp.WebAppClassLoader; -import sun.misc.CompoundEnumeration; -import sun.misc.Resource; -import sun.misc.URLClassPath; import java.io.IOException; import java.net.URL; -import java.net.URLClassLoader; import java.util.ArrayList; +import java.util.Collections; import java.util.Enumeration; import java.util.List; @@ -31,12 +28,25 @@ public class FilteringClassLoader extends WebAppClassLoader { private final List serverResources = new ArrayList(); + private ClassLoader bootClassLoader; + public FilteringClassLoader(Context context) throws IOException { super(context); + findBootClassLoader(); } public FilteringClassLoader(ClassLoader parent, Context context) throws IOException { super(parent, context); + findBootClassLoader(); + } + + protected void findBootClassLoader() { + bootClassLoader = getParent(); + if (bootClassLoader != null) { + while(bootClassLoader.getParent() != null) { + bootClassLoader = bootClassLoader.getParent(); + } + } } public void addServerClass(String serverClass) { @@ -64,31 +74,18 @@ protected Class loadClass(String name, boolean resolve) throws ClassNotFoundE @Override public Enumeration getResources(String name) throws IOException { - for(String serverResource : serverResources) + for(String serverResource : serverResources) { if(name.startsWith(serverResource)) { - Enumeration[] tmp = (Enumeration[]) new Enumeration[2]; - tmp[0] = getBootstrapResources(name); - tmp[1] = findResources(name); - return new CompoundEnumeration(tmp); + final List resources = new ArrayList<>(); + resources.addAll(Collections.list(getBootstrapResources(name))); + resources.addAll(Collections.list(findResources(name))); + return Collections.enumeration(resources); } + } return super.getResources(name); } - private static Enumeration getBootstrapResources(String name) throws IOException { - final Enumeration e = - getBootstrapClassPath().getResources(name); - return new Enumeration () { - public URL nextElement() { - return e.nextElement().getURL(); - } - public boolean hasMoreElements() { - return e.hasMoreElements(); - } - }; - } - - // Returns the URLClassPath that is used for finding system resources. - static URLClassPath getBootstrapClassPath() { - return sun.misc.Launcher.getBootstrapClassPath(); + private Enumeration getBootstrapResources(String name) throws IOException { + return bootClassLoader.getResources(name); } } diff --git a/libs/gretty-runner-jetty93/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java b/libs/gretty-runner-jetty93/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java index df495dcf2..7d97d21d1 100644 --- a/libs/gretty-runner-jetty93/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java +++ b/libs/gretty-runner-jetty93/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java @@ -9,14 +9,11 @@ package org.akhikhl.gretty; import org.eclipse.jetty.webapp.WebAppClassLoader; -import sun.misc.CompoundEnumeration; -import sun.misc.Resource; -import sun.misc.URLClassPath; import java.io.IOException; import java.net.URL; -import java.net.URLClassLoader; import java.util.ArrayList; +import java.util.Collections; import java.util.Enumeration; import java.util.List; @@ -31,12 +28,25 @@ public class FilteringClassLoader extends WebAppClassLoader { private final List serverResources = new ArrayList(); + private ClassLoader bootClassLoader; + public FilteringClassLoader(Context context) throws IOException { super(context); + findBootClassLoader(); } public FilteringClassLoader(ClassLoader parent, Context context) throws IOException { super(parent, context); + findBootClassLoader(); + } + + protected void findBootClassLoader() { + bootClassLoader = getParent(); + if (bootClassLoader != null) { + while(bootClassLoader.getParent() != null) { + bootClassLoader = bootClassLoader.getParent(); + } + } } public void addServerClass(String serverClass) { @@ -64,31 +74,18 @@ protected Class loadClass(String name, boolean resolve) throws ClassNotFoundE @Override public Enumeration getResources(String name) throws IOException { - for(String serverResource : serverResources) + for(String serverResource : serverResources) { if(name.startsWith(serverResource)) { - Enumeration[] tmp = (Enumeration[]) new Enumeration[2]; - tmp[0] = getBootstrapResources(name); - tmp[1] = findResources(name); - return new CompoundEnumeration(tmp); + final List resources = new ArrayList<>(); + resources.addAll(Collections.list(getBootstrapResources(name))); + resources.addAll(Collections.list(findResources(name))); + return Collections.enumeration(resources); } + } return super.getResources(name); } - private static Enumeration getBootstrapResources(String name) throws IOException { - final Enumeration e = - getBootstrapClassPath().getResources(name); - return new Enumeration () { - public URL nextElement() { - return e.nextElement().getURL(); - } - public boolean hasMoreElements() { - return e.hasMoreElements(); - } - }; - } - - // Returns the URLClassPath that is used for finding system resources. - static URLClassPath getBootstrapClassPath() { - return sun.misc.Launcher.getBootstrapClassPath(); + private Enumeration getBootstrapResources(String name) throws IOException { + return bootClassLoader.getResources(name); } } diff --git a/libs/gretty-runner-jetty94/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java b/libs/gretty-runner-jetty94/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java index df495dcf2..7d97d21d1 100644 --- a/libs/gretty-runner-jetty94/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java +++ b/libs/gretty-runner-jetty94/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java @@ -9,14 +9,11 @@ package org.akhikhl.gretty; import org.eclipse.jetty.webapp.WebAppClassLoader; -import sun.misc.CompoundEnumeration; -import sun.misc.Resource; -import sun.misc.URLClassPath; import java.io.IOException; import java.net.URL; -import java.net.URLClassLoader; import java.util.ArrayList; +import java.util.Collections; import java.util.Enumeration; import java.util.List; @@ -31,12 +28,25 @@ public class FilteringClassLoader extends WebAppClassLoader { private final List serverResources = new ArrayList(); + private ClassLoader bootClassLoader; + public FilteringClassLoader(Context context) throws IOException { super(context); + findBootClassLoader(); } public FilteringClassLoader(ClassLoader parent, Context context) throws IOException { super(parent, context); + findBootClassLoader(); + } + + protected void findBootClassLoader() { + bootClassLoader = getParent(); + if (bootClassLoader != null) { + while(bootClassLoader.getParent() != null) { + bootClassLoader = bootClassLoader.getParent(); + } + } } public void addServerClass(String serverClass) { @@ -64,31 +74,18 @@ protected Class loadClass(String name, boolean resolve) throws ClassNotFoundE @Override public Enumeration getResources(String name) throws IOException { - for(String serverResource : serverResources) + for(String serverResource : serverResources) { if(name.startsWith(serverResource)) { - Enumeration[] tmp = (Enumeration[]) new Enumeration[2]; - tmp[0] = getBootstrapResources(name); - tmp[1] = findResources(name); - return new CompoundEnumeration(tmp); + final List resources = new ArrayList<>(); + resources.addAll(Collections.list(getBootstrapResources(name))); + resources.addAll(Collections.list(findResources(name))); + return Collections.enumeration(resources); } + } return super.getResources(name); } - private static Enumeration getBootstrapResources(String name) throws IOException { - final Enumeration e = - getBootstrapClassPath().getResources(name); - return new Enumeration () { - public URL nextElement() { - return e.nextElement().getURL(); - } - public boolean hasMoreElements() { - return e.hasMoreElements(); - } - }; - } - - // Returns the URLClassPath that is used for finding system resources. - static URLClassPath getBootstrapClassPath() { - return sun.misc.Launcher.getBootstrapClassPath(); + private Enumeration getBootstrapResources(String name) throws IOException { + return bootClassLoader.getResources(name); } } diff --git a/libs/gretty-runner-tomcat/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java b/libs/gretty-runner-tomcat/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java index f74c4b236..19ce5ea2b 100644 --- a/libs/gretty-runner-tomcat/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java +++ b/libs/gretty-runner-tomcat/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java @@ -8,14 +8,9 @@ */ package org.akhikhl.gretty; -import sun.misc.CompoundEnumeration; -import sun.misc.Resource; -import sun.misc.URLClassPath; - import java.io.IOException; import java.net.URL; import java.net.URLClassLoader; -import java.security.SecureClassLoader; import java.util.ArrayList; import java.util.Collections; import java.util.Enumeration; @@ -32,8 +27,20 @@ public class FilteringClassLoader extends URLClassLoader { private final List serverResources = new ArrayList(); + private ClassLoader bootClassLoader; + public FilteringClassLoader(ClassLoader parent) { super(new URL[0], parent); + findBootClassLoader(); + } + + protected void findBootClassLoader() { + bootClassLoader = getParent(); + if (bootClassLoader != null) { + while(bootClassLoader.getParent() != null) { + bootClassLoader = bootClassLoader.getParent(); + } + } } public void addServerClass(String serverClass) { @@ -61,33 +68,18 @@ protected Class loadClass(String name, boolean resolve) throws ClassNotFoundE @Override public Enumeration getResources(String name) throws IOException { - for(String serverResource : serverResources) + for(String serverResource : serverResources) { if(name.startsWith(serverResource)) { - Enumeration[] tmp = (Enumeration[]) new Enumeration[2]; - tmp[0] = getBootstrapResources(name); - tmp[1] = findResources(name); - return new CompoundEnumeration(tmp); + final List resources = new ArrayList<>(); + resources.addAll(Collections.list(getBootstrapResources(name))); + resources.addAll(Collections.list(findResources(name))); + return Collections.enumeration(resources); } + } return super.getResources(name); } - private static Enumeration getBootstrapResources(String name) - throws IOException - { - final Enumeration e = - getBootstrapClassPath().getResources(name); - return new Enumeration () { - public URL nextElement() { - return e.nextElement().getURL(); - } - public boolean hasMoreElements() { - return e.hasMoreElements(); - } - }; - } - - // Returns the URLClassPath that is used for finding system resources. - static URLClassPath getBootstrapClassPath() { - return sun.misc.Launcher.getBootstrapClassPath(); + private Enumeration getBootstrapResources(String name) throws IOException { + return bootClassLoader.getResources(name); } }