Skip to content

Commit

Permalink
chore: update to jdk 11 (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
monperrus authored Sep 30, 2021
1 parent a0b1fd0 commit 6ea0dcc
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: java

jdk:
- openjdk8
- openjdk11

script:
- set -e
Expand Down
2 changes: 1 addition & 1 deletion jPerturb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<dependency>
<groupId>fr.inria.gforge.spoon</groupId>
<artifactId>spoon-core</artifactId>
<version>7.2.0-SNAPSHOT</version>
<version>9.0.0</version><!-- 👏 -->
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"));
Expand Down
4 changes: 2 additions & 2 deletions jPerturb/src/test/java/perturbation/enactor/TestEnactor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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"));
Expand Down
8 changes: 5 additions & 3 deletions jPerturb/src/test/java/processor/TestProcessImplicitCast.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
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;
import spoon.reflect.visitor.filter.TypeFilter;
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;
Expand Down Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6ea0dcc

Please sign in to comment.