diff --git a/lang-java-reach-wala/src/main/java/org/eclipse/steady/cg/wala/WalaCallgraphConstructor.java b/lang-java-reach-wala/src/main/java/org/eclipse/steady/cg/wala/WalaCallgraphConstructor.java
index 5dc50d580..d0f68d2e3 100644
--- a/lang-java-reach-wala/src/main/java/org/eclipse/steady/cg/wala/WalaCallgraphConstructor.java
+++ b/lang-java-reach-wala/src/main/java/org/eclipse/steady/cg/wala/WalaCallgraphConstructor.java
@@ -24,6 +24,7 @@
import java.util.Iterator;
import java.util.Set;
+import com.ibm.wala.classLoader.Language;
import org.apache.commons.configuration.Configuration;
import org.apache.logging.log4j.Logger;
import org.eclipse.steady.cg.CallgraphConstructException;
@@ -53,7 +54,7 @@
import com.ibm.wala.ipa.cha.ClassHierarchyFactory;
import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.types.TypeReference;
-import com.ibm.wala.util.config.AnalysisScopeReader;
+import com.ibm.wala.core.util.config.AnalysisScopeReader;
import com.ibm.wala.util.graph.Graph;
import com.ibm.wala.util.graph.impl.SlowSparseNumberedGraph;
@@ -145,13 +146,13 @@ public void setDepClasspath(String _dependenciesClasspath) {
/**
* {@inheritDoc}
*
- * Filter and find all entrypoints in scope
+ *
Filter and find all entrypoints in scope
*/
public void setEntrypoints(Set _constructs)
throws CallgraphConstructException {
try {
this.scope =
- AnalysisScopeReader.makeJavaBinaryAnalysisScope(
+ AnalysisScopeReader.instance.makeJavaBinaryAnalysisScope(
this.classpath, this.excludedPackagesFile);
// The removal of ClassHierarchy.make(AnalysisScope) was made with commit
@@ -207,13 +208,11 @@ public void setEntrypoints(Set
&& (cha.getScope()
.getApplicationLoader()
.equals(klass.getClassLoader().getReference()))) {
- for (Iterator m_iter = klass.getDeclaredMethods().iterator();
- m_iter.hasNext(); ) {
- method = (IMethod) m_iter.next();
- if (!method.isClinit()) {
- method_qname = getCid(method).getQname();
- if (!method.isAbstract() && (_constructs_qname.contains(method_qname))) {
- ep.add(new ArgumentTypeEntrypoint(method, cha));
+ for (IMethod declaredMethod : klass.getDeclaredMethods()) {
+ if (!declaredMethod.isClinit()) {
+ method_qname = getCid(declaredMethod).getQname();
+ if (!declaredMethod.isAbstract() && (_constructs_qname.contains(method_qname))) {
+ ep.add(new ArgumentTypeEntrypoint(declaredMethod, cha));
}
}
}
@@ -334,7 +333,7 @@ public Configuration getConstructorConfiguration() {
/**
* {@inheritDoc}
*
- * Parse command line arguments, and then build callgraph based on these properties
+ * Parse command line arguments, and then build callgraph based on these properties
*/
public void buildCallgraph(boolean _policy) throws CallgraphConstructException {
WalaCallgraphConstructor.log.info(
@@ -374,17 +373,18 @@ public void buildCallgraph(boolean _policy) throws CallgraphConstructException {
if (cg_algorithm.equals("RTA")) {
builder = Util.makeRTABuilder(options, cache, this.cha, this.scope);
} else if (cg_algorithm.equals("0-CFA")) {
- builder = Util.makeZeroCFABuilder(options, cache, this.cha, this.scope);
+ builder = Util.makeZeroCFABuilder(Language.JAVA, options, cache, this.cha, this.scope);
} else if (cg_algorithm.equals("0-ctn-CFA")) {
builder = Util.makeZeroContainerCFABuilder(options, cache, this.cha, this.scope);
} else if (cg_algorithm.equals("vanilla-0-1-CFA")) {
- builder = Util.makeVanillaZeroOneCFABuilder(options, cache, this.cha, this.scope);
+ builder =
+ Util.makeVanillaZeroOneCFABuilder(Language.JAVA, options, cache, this.cha, this.scope);
} else if (cg_algorithm.equals("0-1-CFA")) {
- builder = Util.makeZeroOneCFABuilder(options, cache, this.cha, this.scope);
+ builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, cache, this.cha, this.scope);
} else if (cg_algorithm.equals("0-1-ctn-CFA")) {
builder = Util.makeZeroOneContainerCFABuilder(options, cache, this.cha, this.scope);
} else {
- builder = Util.makeZeroOneCFABuilder(options, cache, this.cha, this.scope);
+ builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, cache, this.cha, this.scope);
}
// Build callgraph based on options and algorithm
diff --git a/lang-java-reach-wala/src/test/java/org/eclipse/steady/cg/wala/WalaCallGraphTest.java b/lang-java-reach-wala/src/test/java/org/eclipse/steady/cg/wala/WalaCallGraphTest.java
index 121a18133..1c12ef48e 100644
--- a/lang-java-reach-wala/src/test/java/org/eclipse/steady/cg/wala/WalaCallGraphTest.java
+++ b/lang-java-reach-wala/src/test/java/org/eclipse/steady/cg/wala/WalaCallGraphTest.java
@@ -128,4 +128,41 @@ public void examplesWalaTest() {
e.printStackTrace();
}
}
+
+ @Test
+ public void examplesWalaTestJdk17() {
+ final ReachabilityAnalyzer ra = new ReachabilityAnalyzer(this.getGoalContext());
+ ra.setCallgraphConstructor(WalaCallgraphConstructor.FRAMEWORK, false);
+
+ // Set classpaths
+ final Set app_paths = new HashSet(), dep_paths = new HashSet();
+ app_paths.add(Paths.get("./src/test/resources/examplesJdk17.jar"));
+ dep_paths.add(Paths.get("./src/test/resources/empty.jar"));
+ ra.setAppClasspaths(app_paths);
+ ra.setDependencyClasspaths(dep_paths);
+
+ // Set the EP manually
+ final Set entrypoint = new HashSet();
+ entrypoint.add(
+ JavaId.toSharedType(JavaId.parseMethodQName("org.example.ExamplesJdk17.main(String[])")));
+ ra.setEntryPoints(entrypoint, PathSource.A2C, false);
+ ra.setAppConstructs(entrypoint);
+
+ // Set the target constructs (manually, rather than using a bug)
+ final Map> target_constructs = new HashMap>();
+ final Set changes = new HashSet();
+ changes.add(JavaId.toSharedType(JavaId.parseMethodQName("org.example.Cat.saySomething()")));
+ changes.add(JavaId.toSharedType(JavaId.parseMethodQName("org.example.Fish.saySomething()")));
+ changes.add(JavaId.toSharedType(JavaId.parseMethodQName("org.example.Dog.saySomething()")));
+ changes.add(JavaId.toSharedType(JavaId.parseMethodQName("org.example.Car.saySomething()")));
+ target_constructs.put("does-not-exist", changes);
+ ra.setTargetConstructs(target_constructs);
+
+ try {
+ ReachabilityAnalyzer.startAnalysis(ra, 600000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
}
diff --git a/lang-java-reach-wala/src/test/resources/ExamplesJdk17.java b/lang-java-reach-wala/src/test/resources/ExamplesJdk17.java
new file mode 100644
index 000000000..bc535652e
--- /dev/null
+++ b/lang-java-reach-wala/src/test/resources/ExamplesJdk17.java
@@ -0,0 +1,80 @@
+/**
+ * This file is part of Eclipse Steady.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * SPDX-FileCopyrightText: Copyright (c) 2018-2020 SAP SE or an SAP affiliate company and Eclipse Steady contributors
+ */
+package org.example;
+
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+sealed abstract class Animal implements Comparable permits Cat, Dog, Fish {
+
+ public abstract void saySomething();
+
+ public int compareTo(Animal _a) {
+ return getClass().getName().compareTo(_a.getClass().getName());
+ }
+}
+
+final class Cat extends Animal {
+ public void saySomething() {
+ System.out.println("purr");
+ }
+}
+
+final class Dog extends Animal {
+ public void saySomething() {
+ System.out.println("woof");
+ }
+}
+
+final class Fish extends Animal {
+ public void saySomething() {
+ System.out.println("...");
+ }
+}
+
+class Car {
+ public void saySomething() {
+ System.out.println("honk!");
+ }
+}
+
+public class ExamplesJdk17 {
+ static SortedSet animals = new TreeSet<>();
+
+ private static Animal createFish() {
+ return new Fish();
+ }
+
+ private static Animal createCat() {
+ Animal cat = new Cat();
+ animals.add(cat);
+ return cat;
+ }
+
+ public static void main(String[] args) {
+ Animal animal;
+ if (args.length == 0) {
+ animal = createCat();
+ animal.saySomething();
+ } else {
+ animal = createFish();
+ animal.saySomething();
+ }
+ }
+}
diff --git a/lang-java-reach-wala/src/test/resources/examplesJdk17.jar b/lang-java-reach-wala/src/test/resources/examplesJdk17.jar
new file mode 100644
index 000000000..7ed42895c
Binary files /dev/null and b/lang-java-reach-wala/src/test/resources/examplesJdk17.jar differ
diff --git a/lang-java-reach/pom.xml b/lang-java-reach/pom.xml
index 8b393bc9c..a382d0227 100755
--- a/lang-java-reach/pom.xml
+++ b/lang-java-reach/pom.xml
@@ -37,7 +37,7 @@
false
-
+
org.eclipse.steady
@@ -51,17 +51,17 @@
com.ibm.wala
com.ibm.wala.core
- 1.4.3
+ 1.6.2
com.ibm.wala
com.ibm.wala.util
- 1.4.3
+ 1.6.2
com.ibm.wala
com.ibm.wala.shrike
- 1.4.3
+ 1.6.2
@@ -80,7 +80,7 @@
org.apache.maven.plugins
maven-resources-plugin
-
+
org.apache.maven.plugins
diff --git a/plugin-maven/pom.xml b/plugin-maven/pom.xml
index 756ca6c8e..07ebd5a32 100644
--- a/plugin-maven/pom.xml
+++ b/plugin-maven/pom.xml
@@ -165,7 +165,7 @@
org.apache.maven.plugins
maven-plugin-plugin
- 3.5.2
+ 3.9.0
steady
true