From 6ea0dcc751715edd24daa487419e9decc3c6cd2e Mon Sep 17 00:00:00 2001 From: Martin Monperrus Date: Thu, 30 Sep 2021 18:59:27 +0000 Subject: [PATCH] chore: update to jdk 11 (#17) --- .travis.yml | 2 +- jPerturb/pom.xml | 2 +- .../test/java/perturbation/TestPerturbationBinaryOp.java | 4 ++-- .../perturbation/TestPerturbationLiteralsVariable.java | 4 ++-- .../src/test/java/perturbation/enactor/TestEnactor.java | 4 ++-- .../java/perturbation/perturbator/TestPerturbator.java | 4 ++-- .../src/test/java/processor/TestProcessImplicitCast.java | 8 +++++--- .../test/java/processor/TestProcessLiteralsVariable.java | 2 ++ 8 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index de195a4..70814a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: java jdk: - - openjdk8 + - openjdk11 script: - set -e diff --git a/jPerturb/pom.xml b/jPerturb/pom.xml index 1e00133..9e90bb6 100644 --- a/jPerturb/pom.xml +++ b/jPerturb/pom.xml @@ -59,7 +59,7 @@ fr.inria.gforge.spoon spoon-core - 7.2.0-SNAPSHOT + 9.0.0 diff --git a/jPerturb/src/test/java/perturbation/TestPerturbationBinaryOp.java b/jPerturb/src/test/java/perturbation/TestPerturbationBinaryOp.java index 6c6fc13..2f98ea1 100644 --- a/jPerturb/src/test/java/perturbation/TestPerturbationBinaryOp.java +++ b/jPerturb/src/test/java/perturbation/TestPerturbationBinaryOp.java @@ -6,6 +6,7 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.net.URL; import java.net.URLClassLoader; import static org.junit.Assert.assertEquals; @@ -25,8 +26,7 @@ public void testPerturbationOnBinaryOperator() throws Exception { launcher.run(); //The pertubation works? - Util.addPathToClassPath(launcher.getModelBuilder().getBinaryOutputDirectory().toURL()); - URLClassLoader classLoaderWithoutOldFile = Util.removeOldFileFromClassPath((URLClassLoader) ClassLoader.getSystemClassLoader()); + URLClassLoader classLoaderWithoutOldFile = new URLClassLoader(new URL[]{launcher.getModelBuilder().getBinaryOutputDirectory().toURL()}, Util.class.getClassLoader() ); Class classPerturbationLocation = classLoaderWithoutOldFile.loadClass("perturbation.location.PerturbationLocation"); Method setEnactor = classPerturbationLocation.getMethod("setEnactor", classLoaderWithoutOldFile.loadClass("perturbation.enactor.Enactor")); diff --git a/jPerturb/src/test/java/perturbation/TestPerturbationLiteralsVariable.java b/jPerturb/src/test/java/perturbation/TestPerturbationLiteralsVariable.java index df2a8ef..10e3afe 100644 --- a/jPerturb/src/test/java/perturbation/TestPerturbationLiteralsVariable.java +++ b/jPerturb/src/test/java/perturbation/TestPerturbationLiteralsVariable.java @@ -8,6 +8,7 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.net.URL; import java.net.URLClassLoader; import java.util.HashMap; import java.util.Map; @@ -32,8 +33,7 @@ public void testPerturbation() throws Exception { CtClass simpleResWithPerturbation = launcher.getFactory().Package().getRootPackage().getElements(new NamedElementFilter<>(CtClass.class, "SimpleRes")).get(0); //The pertubation works? - Util.addPathToClassPath(launcher.getModelBuilder().getBinaryOutputDirectory().toURL()); - URLClassLoader classLoaderWithoutOldFile = Util.removeOldFileFromClassPath((URLClassLoader) ClassLoader.getSystemClassLoader()); + URLClassLoader classLoaderWithoutOldFile = new URLClassLoader(new URL[]{launcher.getModelBuilder().getBinaryOutputDirectory().toURL()}, Util.class.getClassLoader() ); Class classPerturbationLocation = classLoaderWithoutOldFile.loadClass("perturbation.location.PerturbationLocation"); Method setEnactor = classPerturbationLocation.getMethod("setEnactor", classLoaderWithoutOldFile.loadClass("perturbation.enactor.Enactor")); diff --git a/jPerturb/src/test/java/perturbation/enactor/TestEnactor.java b/jPerturb/src/test/java/perturbation/enactor/TestEnactor.java index 3790858..fb1f4e6 100644 --- a/jPerturb/src/test/java/perturbation/enactor/TestEnactor.java +++ b/jPerturb/src/test/java/perturbation/enactor/TestEnactor.java @@ -9,6 +9,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.net.URL; import java.net.URLClassLoader; import java.util.Arrays; @@ -48,8 +49,7 @@ private static void initialisation() throws Exception { simpleResWithPerturbation = launcher.getFactory().Package().getRootPackage().getElements(new NamedElementFilter<>(CtClass.class, "SimpleRes")).get(0); - Util.addPathToClassPath(launcher.getModelBuilder().getBinaryOutputDirectory().toURL()); - classLoaderWithoutOldFile = Util.removeOldFileFromClassPath((URLClassLoader) ClassLoader.getSystemClassLoader()); + classLoaderWithoutOldFile = new URLClassLoader(new URL[]{launcher.getModelBuilder().getBinaryOutputDirectory().toURL()}, Util.class.getClassLoader() ); classPerturbationLocation = classLoaderWithoutOldFile.loadClass("perturbation.location.PerturbationLocation"); setEnactor = classPerturbationLocation.getMethod("setEnactor", classLoaderWithoutOldFile.loadClass("perturbation.enactor.Enactor")); diff --git a/jPerturb/src/test/java/perturbation/perturbator/TestPerturbator.java b/jPerturb/src/test/java/perturbation/perturbator/TestPerturbator.java index 9abce03..faa2bae 100644 --- a/jPerturb/src/test/java/perturbation/perturbator/TestPerturbator.java +++ b/jPerturb/src/test/java/perturbation/perturbator/TestPerturbator.java @@ -9,6 +9,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.net.URL; import java.net.URLClassLoader; import java.util.Arrays; @@ -47,8 +48,7 @@ private static void initialisation() throws Exception { simpleResWithPerturbation = launcher.getFactory().Package().getRootPackage().getElements(new NamedElementFilter<>(CtClass.class, "SimpleRes")).get(0); - Util.addPathToClassPath(launcher.getModelBuilder().getBinaryOutputDirectory().toURL()); - classLoaderWithoutOldFile = Util.removeOldFileFromClassPath((URLClassLoader) ClassLoader.getSystemClassLoader()); + classLoaderWithoutOldFile = new URLClassLoader(new URL[]{launcher.getModelBuilder().getBinaryOutputDirectory().toURL()}, Util.class.getClassLoader() ); classPerturbationLocation = classLoaderWithoutOldFile.loadClass("perturbation.location.PerturbationLocation"); setPerturbator = classPerturbationLocation.getMethod("setPerturbator", classLoaderWithoutOldFile.loadClass("perturbation.perturbator.Perturbator")); diff --git a/jPerturb/src/test/java/processor/TestProcessImplicitCast.java b/jPerturb/src/test/java/processor/TestProcessImplicitCast.java index 31a6692..f112a07 100644 --- a/jPerturb/src/test/java/processor/TestProcessImplicitCast.java +++ b/jPerturb/src/test/java/processor/TestProcessImplicitCast.java @@ -5,6 +5,7 @@ import spoon.reflect.code.CtConstructorCall; import spoon.reflect.code.CtInvocation; import spoon.reflect.code.CtLiteral; +import spoon.reflect.declaration.CtAnnotation; import spoon.reflect.declaration.CtClass; import spoon.reflect.declaration.CtMethod; import spoon.reflect.visitor.filter.NamedElementFilter; @@ -12,6 +13,7 @@ import spoon.support.reflect.code.CtInvocationImpl; import util.Util; +import java.net.URL; import java.net.URLClassLoader; import java.util.List; import java.util.Set; @@ -43,16 +45,16 @@ public void testCast() throws Exception { for (CtLiteral elem : elems) { if (elem.getParent() instanceof CtConstructorCall && ((CtConstructorCall) elem.getParent()).getExecutable().getType().getSimpleName().equals("PerturbationLocationImpl")) continue;// we skip lit introduce by the perturbation + if (elem.getParent() instanceof CtAnnotation) continue; //parent is invokation - assertTrue(elem.getParent() instanceof CtInvocation); + assertTrue(elem.getParent().toString(), elem.getParent() instanceof CtInvocation); //this invokation come from pertubator assertTrue(((CtInvocationImpl) elem.getParent()).getExecutable().getDeclaringType().equals(p.getReference())); } } //We assume if we can't instanciate the class, something went wrong - Util.addPathToClassPath(launcher.getModelBuilder().getBinaryOutputDirectory().toURL()); - URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader(); + ClassLoader sysloader = new URLClassLoader(new URL[]{launcher.getModelBuilder().getBinaryOutputDirectory().toURL()}, Util.class.getClassLoader() ); Class CastResClass = sysloader.loadClass(c.getQualifiedName()); Object CastResInstance = CastResClass.newInstance(); } diff --git a/jPerturb/src/test/java/processor/TestProcessLiteralsVariable.java b/jPerturb/src/test/java/processor/TestProcessLiteralsVariable.java index 8c92c53..6a0d527 100644 --- a/jPerturb/src/test/java/processor/TestProcessLiteralsVariable.java +++ b/jPerturb/src/test/java/processor/TestProcessLiteralsVariable.java @@ -7,6 +7,7 @@ import spoon.reflect.code.CtInvocation; import spoon.reflect.code.CtLiteral; import spoon.reflect.code.CtReturn; +import spoon.reflect.declaration.CtAnnotation; import spoon.reflect.declaration.CtClass; import spoon.reflect.declaration.CtMethod; import spoon.reflect.visitor.filter.NamedElementFilter; @@ -43,6 +44,7 @@ public void testIntroductionOfPerturbation() { for (CtLiteral elem : elems) { if (elem.getParent() instanceof CtConstructorCall && ((CtConstructorCall) elem.getParent()).getExecutable().getType().getSimpleName().equals("PerturbationLocationImpl")) continue;// we skip lit introduce by the perturbation + if (elem.getParent() instanceof CtAnnotation) continue; //parent is invokation assertTrue(elem.getParent() instanceof CtInvocation); //this invokation come from perturbator