branch feature/jdk11 created (now bca90b7)
This is an automated email from the git hooks/post-receive script. New change to branch feature/jdk11 in repository nuiton-utils. See https://gitlab.nuiton.org/nuiton/nuiton-utils.git at bca90b7 Tests are conditionned to URLClassLoader presence. The library can be used with Java 9+ but org.nuiton.util.Resource will not be usable This branch includes the following new commits: new ffb41be Test naming new de67149 Upgrade dependencies : Guava 28.2 ; JUnit 4.13 new 1005951 [iso] setup/teardown method at the top of the class new bca90b7 Tests are conditionned to URLClassLoader presence. The library can be used with Java 9+ but org.nuiton.util.Resource will not be usable The 4 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit bca90b7585f0547177a62ad06e70db7fd2f6e86e Author: Arnaud Thimel <thimel@codelutin.com> Date: Fri Jan 3 18:32:43 2020 +0100 Tests are conditionned to URLClassLoader presence. The library can be used with Java 9+ but org.nuiton.util.Resource will not be usable commit 10059514ff3f111c5d8b5214f12f934313722ddc Author: Arnaud Thimel <thimel@codelutin.com> Date: Fri Jan 3 18:08:34 2020 +0100 [iso] setup/teardown method at the top of the class commit de671495ba9370b1f32b8854869bf460805203fc Author: Arnaud Thimel <thimel@codelutin.com> Date: Fri Jan 3 18:04:20 2020 +0100 Upgrade dependencies : Guava 28.2 ; JUnit 4.13 commit ffb41be0522dd2bdf7afa904329e63f95334a0de Author: Arnaud Thimel <thimel@codelutin.com> Date: Fri Jan 3 18:00:11 2020 +0100 Test naming -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/jdk11 in repository nuiton-utils. See https://gitlab.nuiton.org/nuiton/nuiton-utils.git commit de671495ba9370b1f32b8854869bf460805203fc Author: Arnaud Thimel <thimel@codelutin.com> Date: Fri Jan 3 18:04:20 2020 +0100 Upgrade dependencies : Guava 28.2 ; JUnit 4.13 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index d0b7b3c..ffab262 100644 --- a/pom.xml +++ b/pom.xml @@ -191,7 +191,7 @@ <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> - <version>28.1-jre</version> + <version>28.2-jre</version> </dependency> <dependency> @@ -209,7 +209,7 @@ <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>4.12</version> + <version>4.13</version> <scope>test</scope> </dependency> -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/jdk11 in repository nuiton-utils. See https://gitlab.nuiton.org/nuiton/nuiton-utils.git commit 10059514ff3f111c5d8b5214f12f934313722ddc Author: Arnaud Thimel <thimel@codelutin.com> Date: Fri Jan 3 18:08:34 2020 +0100 [iso] setup/teardown method at the top of the class --- src/test/java/org/nuiton/util/ResourceTest.java | 50 ++++++++++++------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/test/java/org/nuiton/util/ResourceTest.java b/src/test/java/org/nuiton/util/ResourceTest.java index 27be3ce..f8ea5e2 100644 --- a/src/test/java/org/nuiton/util/ResourceTest.java +++ b/src/test/java/org/nuiton/util/ResourceTest.java @@ -54,6 +54,31 @@ public class ResourceTest { // ResourceTest /** Logger. */ private static final Log log = LogFactory.getLog(ResourceTest.class); + // unaltered classloader + static ClassLoader systemClassLoader; + + @BeforeClass + public static void beforeClass() { + systemClassLoader = ClassLoader.getSystemClassLoader(); + } + + @Before + public void beforeTest() throws NoSuchFieldException, IllegalAccessException { + URLClassLoader classLoader = (URLClassLoader) systemClassLoader; + ClassLoader parent = classLoader.getParent(); + ClassLoader currentClassLoader = new URLClassLoader(classLoader.getURLs(), parent); + Field field = ClassLoader.class.getDeclaredField("scl"); + field.setAccessible(true); + field.set(null, currentClassLoader); + } + + @After + public void afterTest() throws NoSuchFieldException, IllegalAccessException { + Field field = ClassLoader.class.getDeclaredField("scl"); + field.setAccessible(true); + field.set(null, systemClassLoader); + } + @Test public void testAddDefaultClassLoader() throws Exception { String javaExecFilename = getJavaExecName(); @@ -125,31 +150,6 @@ public class ResourceTest { // ResourceTest Assert.assertEquals(1, result.size()); } - // unaltered classloader - static ClassLoader systemClassLoader; - - @BeforeClass - public static void beforeClass() { - systemClassLoader = ClassLoader.getSystemClassLoader(); - } - - @Before - public void beforeTest() throws NoSuchFieldException, IllegalAccessException { - URLClassLoader classLoader = (URLClassLoader) systemClassLoader; - ClassLoader parent = classLoader.getParent(); - ClassLoader currentClassLoader = new URLClassLoader(classLoader.getURLs(), parent); - Field field = ClassLoader.class.getDeclaredField("scl"); - field.setAccessible(true); - field.set(null, currentClassLoader); - } - - @After - public void afterTest() throws NoSuchFieldException, IllegalAccessException { - Field field = ClassLoader.class.getDeclaredField("scl"); - field.setAccessible(true); - field.set(null, systemClassLoader); - } - @Test public void testGetURLs() throws Exception { if (log.isInfoEnabled()) { -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/jdk11 in repository nuiton-utils. See https://gitlab.nuiton.org/nuiton/nuiton-utils.git commit bca90b7585f0547177a62ad06e70db7fd2f6e86e Author: Arnaud Thimel <thimel@codelutin.com> Date: Fri Jan 3 18:32:43 2020 +0100 Tests are conditionned to URLClassLoader presence. The library can be used with Java 9+ but org.nuiton.util.Resource will not be usable --- pom.xml | 2 +- src/main/java/org/nuiton/util/Resource.java | 25 +++++++++++++++++-------- src/test/java/org/nuiton/util/ResourceTest.java | 6 ++++++ 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index ffab262..20a0668 100644 --- a/pom.xml +++ b/pom.xml @@ -138,7 +138,7 @@ <signatureArtifactId>java18</signatureArtifactId> <signatureVersion>1.0</signatureVersion> - <nuitonI18nVersion>3.7</nuitonI18nVersion> + <nuitonI18nVersion>4.0-rc-1</nuitonI18nVersion> <!-- i18n configuration --> <i18n.bundles>fr_FR,en_GB,es_ES</i18n.bundles> diff --git a/src/main/java/org/nuiton/util/Resource.java b/src/main/java/org/nuiton/util/Resource.java index ed5fd40..ca7d6ab 100644 --- a/src/main/java/org/nuiton/util/Resource.java +++ b/src/main/java/org/nuiton/util/Resource.java @@ -93,13 +93,17 @@ public class Resource { // Resource * @param url l'url a ajouter */ public static void addClassLoader(ClassLoader classLoader, URL url) { - try { - Method method = URLClassLoader.class.getDeclaredMethod("addURL", - new Class[]{URL.class}); - method.setAccessible(true); - method.invoke(classLoader, url); - } catch (Exception eee) { - throw new RuntimeException(t("nuitonutil.error.add.url.in.classloader", classLoader, eee)); + if (classLoader instanceof URLClassLoader) { + try { + Method method = URLClassLoader.class.getDeclaredMethod("addURL", + new Class[]{URL.class}); + method.setAccessible(true); + method.invoke(classLoader, url); + } catch (Exception eee) { + throw new RuntimeException(t("nuitonutil.error.add.url.in.classloader", classLoader, eee)); + } + } else { + throw new UnsupportedOperationException(Resource.class.getName() + " is not compatible with Java 9+ so far. See https://gitlab.nuiton.org/nuiton/nuiton-utils/issues/319"); } } @@ -196,7 +200,12 @@ public class Resource { // Resource */ public static List<URL> getURLs(String pattern, URLClassLoader classLoader) { if (classLoader == null) { - classLoader = (URLClassLoader) ClassLoader.getSystemClassLoader(); + ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); + if (systemClassLoader instanceof URLClassLoader) { + classLoader = (URLClassLoader) systemClassLoader; + } else { + throw new UnsupportedOperationException(Resource.class.getName() + " is not compatible with Java 9+ so far. See https://gitlab.nuiton.org/nuiton/nuiton-utils/issues/319"); + } } URL[] arrayURL = ClassLoaderUtil.getURLs(classLoader); return getURLs(pattern, arrayURL); diff --git a/src/test/java/org/nuiton/util/ResourceTest.java b/src/test/java/org/nuiton/util/ResourceTest.java index f8ea5e2..e047949 100644 --- a/src/test/java/org/nuiton/util/ResourceTest.java +++ b/src/test/java/org/nuiton/util/ResourceTest.java @@ -64,6 +64,12 @@ public class ResourceTest { // ResourceTest @Before public void beforeTest() throws NoSuchFieldException, IllegalAccessException { + String errorMessage = "Test is disabled because " + Resource.class.getName() + " is not compatible with Java 9+ so far. See https://gitlab.nuiton.org/nuiton/nuiton-utils/issues/319"; + boolean testEnabled = systemClassLoader instanceof URLClassLoader; + if (!testEnabled && log.isErrorEnabled()) { + log.error(errorMessage); + } + Assume.assumeTrue(errorMessage, testEnabled); URLClassLoader classLoader = (URLClassLoader) systemClassLoader; ClassLoader parent = classLoader.getParent(); ClassLoader currentClassLoader = new URLClassLoader(classLoader.getURLs(), parent); -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm