diff --git a/.gitignore b/.gitignore index b687dd359..f75e915da 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ com.ibm.wala.cast.js.test/examples-src/ajaxslt/ com.ibm.wala.core.testdata/@dot/ com.ibm.wala.core.testdata/lib/ com.ibm.wala.cast.js.html.nu_validator/lib/ +com.ibm.wala.cast.java.test/testdata/ diff --git a/README.md b/README.md index cb52a9247..27747ed99 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,2 @@ -This is a mirror of the WALA SVN repository. It -is maintained manually for now, but more official support may be added in the -future. For more details on WALA, see the -WALA home page. +This is the main source repository for WALA. For more details on WALA, see the WALA home page. diff --git a/com.ibm.wala.cast.java.jdt.test/launchers/JDTJava15IRTests.launch b/com.ibm.wala.cast.java.jdt.test/launchers/JDTJava15IRTests.launch index fdd62d650..634f9f23e 100644 --- a/com.ibm.wala.cast.java.jdt.test/launchers/JDTJava15IRTests.launch +++ b/com.ibm.wala.cast.java.jdt.test/launchers/JDTJava15IRTests.launch @@ -25,17 +25,17 @@ - + - + - - + + diff --git a/com.ibm.wala.cast.java.jdt.test/launchers/JDTJavaIRTests.launch b/com.ibm.wala.cast.java.jdt.test/launchers/JDTJavaIRTests.launch index 085e21a68..f0e0fb214 100644 --- a/com.ibm.wala.cast.java.jdt.test/launchers/JDTJavaIRTests.launch +++ b/com.ibm.wala.cast.java.jdt.test/launchers/JDTJavaIRTests.launch @@ -25,17 +25,17 @@ - + - + - - + + diff --git a/com.ibm.wala.cast.java.jdt.test/source/com/ibm/wala/cast/java/test/JDTJava15IRTests.java b/com.ibm.wala.cast.java.jdt.test/source/com/ibm/wala/cast/java/test/JDTJava15IRTests.java index 6cbec7670..3311d5b78 100644 --- a/com.ibm.wala.cast.java.jdt.test/source/com/ibm/wala/cast/java/test/JDTJava15IRTests.java +++ b/com.ibm.wala.cast.java.jdt.test/source/com/ibm/wala/cast/java/test/JDTJava15IRTests.java @@ -24,11 +24,11 @@ import com.ibm.wala.cast.java.test.ide.IDEIRTestUtil; import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil; import com.ibm.wala.core.tests.plugin.CoreTestsPlugin; import com.ibm.wala.ide.tests.util.EclipseTestUtil; +import com.ibm.wala.ide.util.EclipseFileProvider; import com.ibm.wala.ipa.callgraph.AnalysisScope; import com.ibm.wala.ipa.callgraph.Entrypoint; import com.ibm.wala.ipa.callgraph.impl.Util; import com.ibm.wala.ipa.cha.IClassHierarchy; -import com.ibm.wala.util.io.FileProvider; public class JDTJava15IRTests extends IRTests { @@ -62,7 +62,7 @@ public class JDTJava15IRTests extends IRTests { }; try { - engine.setExclusionsFile(FileProvider + engine.setExclusionsFile((new EclipseFileProvider()) .getFileFromPlugin(CoreTestsPlugin.getDefault(), CallGraphTestUtil.REGRESSION_EXCLUSIONS).getAbsolutePath()); } catch (IOException e) { Assert.assertFalse("Cannot find exclusions file", true); diff --git a/com.ibm.wala.cast.java.jdt.test/source/com/ibm/wala/cast/java/test/JDTJavaIRTests.java b/com.ibm.wala.cast.java.jdt.test/source/com/ibm/wala/cast/java/test/JDTJavaIRTests.java index cdb318467..8884ee843 100644 --- a/com.ibm.wala.cast.java.jdt.test/source/com/ibm/wala/cast/java/test/JDTJavaIRTests.java +++ b/com.ibm.wala.cast.java.jdt.test/source/com/ibm/wala/cast/java/test/JDTJavaIRTests.java @@ -54,11 +54,11 @@ import com.ibm.wala.cast.java.test.ide.IDEIRTestUtil; import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil; import com.ibm.wala.core.tests.plugin.CoreTestsPlugin; import com.ibm.wala.ide.tests.util.EclipseTestUtil; +import com.ibm.wala.ide.util.EclipseFileProvider; import com.ibm.wala.ipa.callgraph.AnalysisScope; import com.ibm.wala.ipa.callgraph.Entrypoint; import com.ibm.wala.ipa.callgraph.impl.Util; import com.ibm.wala.ipa.cha.IClassHierarchy; -import com.ibm.wala.util.io.FileProvider; public class JDTJavaIRTests extends JavaIRTests { @@ -96,7 +96,7 @@ public class JDTJavaIRTests extends JavaIRTests { }; try { - engine.setExclusionsFile(FileProvider + engine.setExclusionsFile((new EclipseFileProvider()) .getFileFromPlugin(CoreTestsPlugin.getDefault(), CallGraphTestUtil.REGRESSION_EXCLUSIONS).getAbsolutePath()); } catch (IOException e) { Assert.assertFalse("Cannot find exclusions file", true); diff --git a/com.ibm.wala.cast.java.polyglot/source/com/ibm/wala/cast/java/client/polyglot/EclipseProjectSourceAnalysisEngine.java b/com.ibm.wala.cast.java.polyglot/source/com/ibm/wala/cast/java/client/polyglot/EclipseProjectSourceAnalysisEngine.java index f40398eed..a1dd90d78 100644 --- a/com.ibm.wala.cast.java.polyglot/source/com/ibm/wala/cast/java/client/polyglot/EclipseProjectSourceAnalysisEngine.java +++ b/com.ibm.wala.cast.java.polyglot/source/com/ibm/wala/cast/java/client/polyglot/EclipseProjectSourceAnalysisEngine.java @@ -25,7 +25,8 @@ import com.ibm.wala.classLoader.BinaryDirectoryTreeModule; import com.ibm.wala.classLoader.ClassLoaderFactory; import com.ibm.wala.classLoader.Module; import com.ibm.wala.classLoader.SourceDirectoryTreeModule; -import com.ibm.wala.core.plugin.CorePlugin; +import com.ibm.wala.ide.plugin.CorePlugin; +import com.ibm.wala.ide.util.EclipseFileProvider; import com.ibm.wala.ide.util.EclipseProjectPath; import com.ibm.wala.ide.util.EclipseProjectPath.Loader; import com.ibm.wala.ipa.callgraph.AnalysisCache; @@ -64,7 +65,7 @@ public class EclipseProjectSourceAnalysisEngine extends EclipseProjectAnalysisEn super(project); this.fileExt = fileExt; try { - setExclusionsFile(FileProvider.getFileFromPlugin(CorePlugin.getDefault(), "J2SEClassHierarchyExclusions.txt") + setExclusionsFile((new EclipseFileProvider()).getFileFromPlugin(CorePlugin.getDefault(), "J2SEClassHierarchyExclusions.txt") .getAbsolutePath()); } catch (IOException e) { Assertions.UNREACHABLE("Cannot find exclusions file"); diff --git a/com.ibm.wala.cast.java.test.data/build.xml b/com.ibm.wala.cast.java.test.data/build.xml index f85fb608d..1551c115a 100644 --- a/com.ibm.wala.cast.java.test.data/build.xml +++ b/com.ibm.wala.cast.java.test.data/build.xml @@ -1,70 +1,89 @@ - - - - + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/com.ibm.wala.cast.js.rhino.test/META-INF/MANIFEST.MF b/com.ibm.wala.cast.js.rhino.test/META-INF/MANIFEST.MF index a29cbbf82..8b7eefa49 100644 --- a/com.ibm.wala.cast.js.rhino.test/META-INF/MANIFEST.MF +++ b/com.ibm.wala.cast.js.rhino.test/META-INF/MANIFEST.MF @@ -13,7 +13,8 @@ Require-Bundle: org.eclipse.core.runtime, com.ibm.wala.cast.js.test;bundle-version="1.0.0", com.ibm.wala.cast.test;bundle-version="1.0.0", com.ibm.wala.core.tests;bundle-version="1.1.3", - org.junit4;bundle-version="4.3.1" + org.junit4;bundle-version="4.3.1", + com.ibm.wala.ide;bundle-version="1.1.3" Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-ActivationPolicy: lazy Export-Package: com.ibm.wala.cast.js.test diff --git a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/rhino/test/HTMLCGBuilder.java b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/rhino/test/HTMLCGBuilder.java index c73766cef..13de56d3f 100644 --- a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/rhino/test/HTMLCGBuilder.java +++ b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/rhino/test/HTMLCGBuilder.java @@ -20,13 +20,13 @@ import com.ibm.wala.cast.js.ipa.callgraph.correlations.extraction.CorrelatedPair import com.ibm.wala.cast.js.test.JSCallGraphBuilderUtil; import com.ibm.wala.cast.js.test.JSCallGraphBuilderUtil.CGBuilderType; import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory; +import com.ibm.wala.ide.util.ProgressMaster; +import com.ibm.wala.ide.util.ProgressMonitorDelegate; import com.ibm.wala.ipa.callgraph.CGNode; import com.ibm.wala.ipa.callgraph.CallGraph; import com.ibm.wala.ipa.callgraph.CallGraphBuilderCancelException; import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis; import com.ibm.wala.ipa.cha.ClassHierarchyException; -import com.ibm.wala.util.ProgressMaster; -import com.ibm.wala.util.ProgressMonitorDelegate; import com.ibm.wala.util.io.CommandLine; import com.ibm.wala.util.io.FileProvider; @@ -125,7 +125,7 @@ public class HTMLCGBuilder { // first try interpreting as local file name, if that doesn't work just // assume it's a URL try { - File f = FileProvider.getFileFromClassLoader(src, HTMLCGBuilder.class.getClassLoader()); + File f = (new FileProvider()).getFileFromClassLoader(src, HTMLCGBuilder.class.getClassLoader()); URL url = f.toURI().toURL(); return url; } catch (FileNotFoundException fnfe) { diff --git a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/correlations/CorrelationFinder.java b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/correlations/CorrelationFinder.java index f5a5e5403..965f5f384 100644 --- a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/correlations/CorrelationFinder.java +++ b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/correlations/CorrelationFinder.java @@ -270,7 +270,7 @@ public class CorrelationFinder { private URL toUrl(String src) throws MalformedURLException { // first try interpreting as local file name, if that doesn't work just assume it's a URL try { - File f = FileProvider.getFileFromClassLoader(src, this.getClass().getClassLoader()); + File f = (new FileProvider()).getFileFromClassLoader(src, this.getClass().getClassLoader()); URL url = f.toURI().toURL(); return url; } catch(FileNotFoundException fnfe) { diff --git a/com.ibm.wala.cast/META-INF/MANIFEST.MF b/com.ibm.wala.cast/META-INF/MANIFEST.MF index 4376367ce..251cd5384 100644 --- a/com.ibm.wala.cast/META-INF/MANIFEST.MF +++ b/com.ibm.wala.cast/META-INF/MANIFEST.MF @@ -7,7 +7,8 @@ Bundle-Activator: com.ibm.wala.cast.plugin.AstPlugin Bundle-Vendor: IBM Require-Bundle: com.ibm.wala.core, com.ibm.wala.shrike, - org.eclipse.core.runtime + org.eclipse.core.runtime, + com.ibm.wala.ide;bundle-version="1.1.3" Bundle-ActivationPolicy: lazy Export-Package: com.ibm.wala.cast.analysis.typeInference, com.ibm.wala.cast.ipa.callgraph, diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/translator/NativeBridge.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/translator/NativeBridge.java index 30dd8b2a1..7c9cd14f8 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/translator/NativeBridge.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/translator/NativeBridge.java @@ -11,7 +11,7 @@ package com.ibm.wala.cast.ir.translator; import com.ibm.wala.cast.tree.CAst; -import com.ibm.wala.core.plugin.CorePlugin; +import com.ibm.wala.ide.plugin.CorePlugin; /** * superclass for CAst parsers / translators making use of native code. performs diff --git a/com.ibm.wala.core.tests/META-INF/MANIFEST.MF b/com.ibm.wala.core.tests/META-INF/MANIFEST.MF index 0e21e7bab..f06b6d347 100644 --- a/com.ibm.wala.core.tests/META-INF/MANIFEST.MF +++ b/com.ibm.wala.core.tests/META-INF/MANIFEST.MF @@ -7,7 +7,8 @@ Bundle-Vendor: %providerName Require-Bundle: com.ibm.wala.shrike, com.ibm.wala.core, org.eclipse.core.runtime, - org.junit4;bundle-version="4.3.1" + org.junit4;bundle-version="4.3.1", + com.ibm.wala.ide;bundle-version="1.1.3" Bundle-Localization: plugin Export-Package: com.ibm.wala.core.tests.basic, com.ibm.wala.core.tests.callGraph, diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTestUtil.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTestUtil.java index 578d06a3d..d2fc631e1 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTestUtil.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTestUtil.java @@ -45,7 +45,7 @@ public class CallGraphTestUtil { private static final boolean CHECK_FOOTPRINT = false; public static AnalysisScope makeJ2SEAnalysisScope(String scopeFile, String exclusionsFile) throws IOException { - AnalysisScope scope = AnalysisScopeReader.readJavaScope(scopeFile, FileProvider.getFile(exclusionsFile), MY_CLASSLOADER); + AnalysisScope scope = AnalysisScopeReader.readJavaScope(scopeFile, (new FileProvider()).getFile(exclusionsFile), MY_CLASSLOADER); return scope; } diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/DupFieldsTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/DupFieldsTest.java index 84b3f6833..a17c623c7 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/DupFieldsTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/DupFieldsTest.java @@ -34,7 +34,7 @@ public class DupFieldsTest extends WalaTestCase { @Test public void testDupFieldNames() throws IOException, ClassHierarchyException { AnalysisScope scope = null; - scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, FileProvider.getFile("J2SEClassHierarchyExclusions.txt"), DupFieldsTest.class.getClassLoader()); + scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, (new FileProvider()).getFile("J2SEClassHierarchyExclusions.txt"), DupFieldsTest.class.getClassLoader()); ClassHierarchy cha = ClassHierarchy.make(scope); TypeReference ref = TypeReference.findOrCreate(ClassLoaderReference.Application, "LDupFieldName"); IClass klass = cha.lookupClass(ref); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/ExclusionsTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/ExclusionsTest.java index 51dd5ef9c..40036d3e2 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/ExclusionsTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/ExclusionsTest.java @@ -28,7 +28,7 @@ public class ExclusionsTest { @Test public void testExclusions() throws IOException { - AnalysisScope scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, FileProvider.getFile("GUIExclusions.txt"), + AnalysisScope scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, (new FileProvider()).getFile("GUIExclusions.txt"), ExclusionsTest.class.getClassLoader()); TypeReference buttonRef = TypeReference.findOrCreate(ClassLoaderReference.Application, StringStuff.deployment2CanonicalTypeString("java.awt.Button")); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/GetTargetsTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/GetTargetsTest.java index bb6e1d662..638fa2c66 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/GetTargetsTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/GetTargetsTest.java @@ -48,7 +48,7 @@ public class GetTargetsTest extends WalaTestCase { @BeforeClass public static void beforeClass() throws Exception { - scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, FileProvider.getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); + scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, (new FileProvider()).getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); ClassLoaderFactory factory = new ClassLoaderFactoryImpl(scope.getExclusions() ); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/InnerClassesTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/InnerClassesTest.java index 5b98443a7..2e01d6405 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/InnerClassesTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/InnerClassesTest.java @@ -48,7 +48,7 @@ public class InnerClassesTest extends WalaTestCase { @BeforeClass public static void beforeClass() throws Exception { - scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, FileProvider.getFile("J2SEClassHierarchyExclusions.txt"), + scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, (new FileProvider()).getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); ClassLoaderFactory factory = new ClassLoaderFactoryImpl(scope.getExclusions()); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/InterfaceTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/InterfaceTest.java index 446abf8e9..16518dc82 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/InterfaceTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/InterfaceTest.java @@ -45,7 +45,7 @@ public class InterfaceTest extends WalaTestCase { @BeforeClass public static void beforeClass() throws Exception { - scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, FileProvider.getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); + scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, (new FileProvider()).getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); ClassLoaderFactory factory = new ClassLoaderFactoryImpl(scope.getExclusions() ); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/LibraryVersionTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/LibraryVersionTest.java index 36cf390c9..edee8c8a7 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/LibraryVersionTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/LibraryVersionTest.java @@ -34,7 +34,7 @@ public class LibraryVersionTest extends WalaTestCase { private static final ClassLoader MY_CLASSLOADER = DeterministicIRTest.class.getClassLoader(); @Test public void testLibraryVersion() throws IOException { - AnalysisScope scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, FileProvider.getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); + AnalysisScope scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, (new FileProvider()).getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); System.err.println("java library version is " + scope.getJavaLibraryVersion()); Assert.assertTrue(scope.isJava16Libraries() || scope.isJava15Libraries()||scope.isJava14Libraries()); } diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/AnnotationTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/AnnotationTest.java index e003fac7c..52b1d0e22 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/AnnotationTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/AnnotationTest.java @@ -41,7 +41,7 @@ public class AnnotationTest extends WalaTestCase { @BeforeClass public static void before() throws IOException, ClassHierarchyException { AnalysisScope scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, - FileProvider.getFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS), AnnotationTest.class.getClassLoader()); + (new FileProvider()).getFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS), AnnotationTest.class.getClassLoader()); cha = ClassHierarchy.make(scope); } diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/CFGSanitizerTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/CFGSanitizerTest.java index a262e436e..59cff7f41 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/CFGSanitizerTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/CFGSanitizerTest.java @@ -53,7 +53,7 @@ public class CFGSanitizerTest extends WalaTestCase { */ @Test public void testSyntheticEdgeToExit() throws IOException, IllegalArgumentException, WalaException { - AnalysisScope scope = AnalysisScopeReader.makePrimordialScope(FileProvider.getFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS)); + AnalysisScope scope = AnalysisScopeReader.makePrimordialScope((new FileProvider()).getFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS)); ClassHierarchy cha = ClassHierarchy.make(scope); ClassLoader cl = CFGSanitizerTest.class.getClassLoader(); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/CFGTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/CFGTest.java index 930ca720b..c04e5a357 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/CFGTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/CFGTest.java @@ -56,7 +56,7 @@ public class CFGTest extends WalaTestCase { public static void beforeClass() throws Exception { scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, - FileProvider.getFile("J2SEClassHierarchyExclusions.txt"), CFGTest.class.getClassLoader()); + (new FileProvider()).getFile("J2SEClassHierarchyExclusions.txt"), CFGTest.class.getClassLoader()); ClassLoaderFactory factory = new ClassLoaderFactoryImpl(scope.getExclusions()); try { diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/CornerCasesTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/CornerCasesTest.java index 7ca0919d4..dd77575d2 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/CornerCasesTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/CornerCasesTest.java @@ -53,7 +53,7 @@ public class CornerCasesTest extends WalaTestCase { */ @Test public void testBug38484() throws ClassHierarchyException, IOException { AnalysisScope scope = null; - scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, FileProvider.getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); + scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, (new FileProvider()).getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); ClassHierarchy cha = ClassHierarchy.make(scope); TypeReference t = TypeReference.findOrCreateClass(scope.getApplicationLoader(), "cornerCases", "YuckyInterface"); IClass klass = cha.lookupClass(t); @@ -71,7 +71,7 @@ public class CornerCasesTest extends WalaTestCase { */ @Test public void testBug38540() throws ClassHierarchyException, IOException { AnalysisScope scope = null; - scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, FileProvider.getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); + scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, (new FileProvider()).getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); AnalysisOptions options = new AnalysisOptions(); ClassHierarchy cha = ClassHierarchy.make(scope); TypeReference t = TypeReference.findOrCreateClass(scope.getApplicationLoader(), "cornerCases", "Main"); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/DeterministicIRTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/DeterministicIRTest.java index 981599d37..b2601aa47 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/DeterministicIRTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/DeterministicIRTest.java @@ -66,7 +66,7 @@ public class DeterministicIRTest extends WalaTestCase { public static void beforeClass() throws Exception { scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, - FileProvider.getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); + (new FileProvider()).getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); options = new AnalysisOptions(scope, null); cache = new AnalysisCache(); ClassLoaderFactory factory = new ClassLoaderFactoryImpl(scope.getExclusions()); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/LocalNamesTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/LocalNamesTest.java index ccfb7d35b..f3cec2325 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/LocalNamesTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/LocalNamesTest.java @@ -68,7 +68,7 @@ public class LocalNamesTest extends WalaTestCase { public static void beforeClass() throws Exception { scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, - FileProvider.getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); + (new FileProvider()).getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); options = new AnalysisOptions(scope, null); cache = new AnalysisCache(); @@ -100,7 +100,7 @@ public class LocalNamesTest extends WalaTestCase { @Test public void testAliasNames() { try { - AnalysisScope scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, FileProvider + AnalysisScope scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, (new FileProvider()) .getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); ClassHierarchy cha = ClassHierarchy.make(scope); TypeReference t = TypeReference.findOrCreateClass(scope.getApplicationLoader(), "cornerCases", "AliasNames"); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/MultiNewArrayTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/MultiNewArrayTest.java index c9bfc6fd6..9fdfd1c77 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/MultiNewArrayTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/MultiNewArrayTest.java @@ -41,7 +41,7 @@ public class MultiNewArrayTest extends WalaTestCase { @Test public void testMultiNewArray1() throws IOException, ClassHierarchyException { AnalysisScope scope = null; - scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, FileProvider.getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); + scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, (new FileProvider()).getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); ClassHierarchy cha = ClassHierarchy.make(scope); IClass klass = cha.lookupClass(TypeReference.findOrCreate(ClassLoaderReference.Application, TestConstants.MULTI_DIM_MAIN)); Assert.assertTrue(klass != null); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/typeInference/TypeInferenceTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/typeInference/TypeInferenceTest.java index ec8fb60ba..4371badcf 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/typeInference/TypeInferenceTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/typeInference/TypeInferenceTest.java @@ -64,7 +64,7 @@ public class TypeInferenceTest extends WalaTestCase { @BeforeClass public static void beforeClass() throws Exception { - scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, FileProvider.getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); + scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, (new FileProvider()).getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); options = new AnalysisOptions(scope, null); cache = new AnalysisCache(); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/demandpa/driver/DemandCastChecker.java b/com.ibm.wala.core.tests/src/com/ibm/wala/demandpa/driver/DemandCastChecker.java index b4a16458d..9e22eba9c 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/demandpa/driver/DemandCastChecker.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/demandpa/driver/DemandCastChecker.java @@ -52,6 +52,8 @@ import com.ibm.wala.demandpa.alg.statemachine.StateMachineFactory; import com.ibm.wala.demandpa.flowgraph.IFlowLabel; import com.ibm.wala.demandpa.util.MemoryAccessMap; import com.ibm.wala.demandpa.util.SimpleMemoryAccessMap; +import com.ibm.wala.ide.util.ProgressMaster; +import com.ibm.wala.ide.util.ProgressMonitorDelegate; import com.ibm.wala.ipa.callgraph.AnalysisCache; import com.ibm.wala.ipa.callgraph.AnalysisOptions; import com.ibm.wala.ipa.callgraph.AnalysisScope; @@ -77,8 +79,6 @@ import com.ibm.wala.types.ClassLoaderReference; import com.ibm.wala.types.TypeReference; import com.ibm.wala.util.CancelException; import com.ibm.wala.util.Predicate; -import com.ibm.wala.util.ProgressMaster; -import com.ibm.wala.util.ProgressMonitorDelegate; import com.ibm.wala.util.WalaException; import com.ibm.wala.util.collections.Pair; import com.ibm.wala.util.debug.Assertions; diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/analysis/dataflow/DataflowTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/analysis/dataflow/DataflowTest.java index 1aafca3bd..d52905901 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/analysis/dataflow/DataflowTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/analysis/dataflow/DataflowTest.java @@ -67,7 +67,7 @@ public class DataflowTest extends WalaTestCase { public static void beforeClass() throws Exception { scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, - FileProvider.getFile("J2SEClassHierarchyExclusions.txt"), DataflowTest.class.getClassLoader()); + (new FileProvider()).getFile("J2SEClassHierarchyExclusions.txt"), DataflowTest.class.getClassLoader()); try { cha = ClassHierarchy.make(scope); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/JavaViewerDriver.java b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/JavaViewerDriver.java index 4d4761af7..a9ccf9f74 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/JavaViewerDriver.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/JavaViewerDriver.java @@ -40,7 +40,7 @@ public class JavaViewerDriver { private static void run(String classPath, String exclusionFilePath) throws IOException, ClassHierarchyException, CallGraphBuilderCancelException{ - File exclusionFile = FileProvider.getFile(exclusionFilePath); + File exclusionFile = (new FileProvider()).getFile(exclusionFilePath); AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(classPath, exclusionFile != null ? exclusionFile : new File(CallGraphTestUtil.REGRESSION_EXCLUSIONS)); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFCallGraph.java b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFCallGraph.java index 6b443d2ee..49a282361 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFCallGraph.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFCallGraph.java @@ -108,7 +108,7 @@ public class PDFCallGraph { */ public static Process run(String appJar, String exclusionFile) throws IllegalArgumentException, CancelException { try { - Graph g = buildPrunedCallGraph(appJar, FileProvider.getFile(exclusionFile)); + Graph g = buildPrunedCallGraph(appJar, (new FileProvider()).getFile(exclusionFile)); Properties p = null; try { diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFControlDependenceGraph.java b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFControlDependenceGraph.java index 809c35a38..445f93aeb 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFControlDependenceGraph.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFControlDependenceGraph.java @@ -87,7 +87,7 @@ public class PDFControlDependenceGraph { if (PDFCallGraph.isDirectory(appJar)) { appJar = PDFCallGraph.findJarFiles(new String[] { appJar }); } - AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(appJar, FileProvider.getFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS)); + AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(appJar, (new FileProvider()).getFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS)); ClassHierarchy cha = ClassHierarchy.make(scope); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFSDG.java b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFSDG.java index 526b05ac7..d02ef598f 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFSDG.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFSDG.java @@ -117,7 +117,7 @@ public class PDFSDG { */ public static Process run(String appJar, String mainClass, DataDependenceOptions dOptions, ControlDependenceOptions cOptions) throws IllegalArgumentException, CancelException, IOException { try { - AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(appJar, FileProvider.getFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS)); + AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(appJar, (new FileProvider()).getFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS)); // generate a WALA-consumable wrapper around the incoming scope object diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFSlice.java b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFSlice.java index de0661bd9..a08a1b8f8 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFSlice.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFSlice.java @@ -145,7 +145,7 @@ public class PDFSlice { IOException { try { // create an analysis scope representing the appJar as a J2SE application - AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(appJar, FileProvider + AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(appJar, (new FileProvider()) .getFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS)); // build a class hierarchy, call graph, and system dependence graph diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFTypeHierarchy.java b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFTypeHierarchy.java index c7c6cdb98..eb01049ce 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFTypeHierarchy.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFTypeHierarchy.java @@ -71,7 +71,7 @@ public class PDFTypeHierarchy { try { validateCommandLine(args); String classpath = args[CLASSPATH_INDEX]; - AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(classpath, FileProvider.getFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS)); + AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(classpath, (new FileProvider()).getFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS)); // invoke WALA to build a class hierarchy ClassHierarchy cha = ClassHierarchy.make(scope); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFWalaIR.java b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFWalaIR.java index 57fd0b26e..6cc17d800 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFWalaIR.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFWalaIR.java @@ -72,7 +72,7 @@ public class PDFWalaIR { // Build an AnalysisScope which represents the set of classes to analyze. In particular, // we will analyze the contents of the appJar jar file and the Java standard libraries. - AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(appJar, FileProvider + AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(appJar, (new FileProvider()) .getFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS)); // Build a class hierarchy representing all classes to analyze. This step will read the class diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/properties/WalaExamplesProperties.java b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/properties/WalaExamplesProperties.java index 6f2226672..b3ecb044e 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/properties/WalaExamplesProperties.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/properties/WalaExamplesProperties.java @@ -43,7 +43,7 @@ public final class WalaExamplesProperties { throw new IllegalStateException("failed to find URL for wala.examples.properties"); } - return new File(FileProvider.filePathFromURL(url)).getParentFile().getParentFile().getAbsolutePath(); + return new File((new FileProvider()).filePathFromURL(url)).getParentFile().getParentFile().getAbsolutePath(); } } \ No newline at end of file diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/util/io/FileProviderTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/util/io/FileProviderTest.java index 6fda01327..6e8e88772 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/util/io/FileProviderTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/util/io/FileProviderTest.java @@ -17,7 +17,7 @@ public class FileProviderTest { URL url = new URL("file:///c:/my/File.jar"); String expected = "/c:/my/File.jar"; // exercise: - String actual = FileProvider.filePathFromURL(url); + String actual = (new FileProvider()).filePathFromURL(url); // verify: assertEquals(expected, actual); } @@ -29,7 +29,7 @@ public class FileProviderTest { URL url = new URL("file:///[Eclipse]/File.jar"); String expected = PlatformUtil.onWindows() ? "/C:/[Eclipse]/File.jar" : "/[Eclipse]/File.jar"; // exercise: - String actual = FileProvider.filePathFromURL(url); + String actual = (new FileProvider()).filePathFromURL(url); // verify: assertEquals(expected, actual); } diff --git a/com.ibm.wala.core/META-INF/MANIFEST.MF b/com.ibm.wala.core/META-INF/MANIFEST.MF index 31e5701cb..3a178c5e0 100644 --- a/com.ibm.wala.core/META-INF/MANIFEST.MF +++ b/com.ibm.wala.core/META-INF/MANIFEST.MF @@ -4,12 +4,9 @@ Eclipse-LazyStart: true Bundle-Name: %pluginName Bundle-SymbolicName: com.ibm.wala.core Bundle-Version: 1.1.3.qualifier -Bundle-Activator: com.ibm.wala.core.plugin.CorePlugin Bundle-Vendor: %providerName Bundle-Localization: plugin Require-Bundle: com.ibm.wala.shrike, - org.eclipse.core.runtime, - org.eclipse.core.resources;resolution:=optional, com.ibm.wala.util;bundle-version="1.0.0";visibility:=reexport Bundle-ActivationPolicy: lazy Export-Package: ., diff --git a/com.ibm.wala.core/src/com/ibm/wala/classLoader/AbstractURLModule.java b/com.ibm.wala.core/src/com/ibm/wala/classLoader/AbstractURLModule.java index 00a838411..c26c998b0 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/classLoader/AbstractURLModule.java +++ b/com.ibm.wala.core/src/com/ibm/wala/classLoader/AbstractURLModule.java @@ -40,7 +40,7 @@ public abstract class AbstractURLModule implements Module, ModuleEntry { if (con instanceof JarURLConnection) return ((JarURLConnection) con).getEntryName(); else - return FileProvider.filePathFromURL(url); + return (new FileProvider()).filePathFromURL(url); } catch (IOException e) { Assertions.UNREACHABLE(); return null; diff --git a/com.ibm.wala.core/src/com/ibm/wala/classLoader/ClassLoaderImpl.java b/com.ibm.wala.core/src/com/ibm/wala/classLoader/ClassLoaderImpl.java index bbdeb9f0f..aae02f476 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/classLoader/ClassLoaderImpl.java +++ b/com.ibm.wala.core/src/com/ibm/wala/classLoader/ClassLoaderImpl.java @@ -510,7 +510,7 @@ public class ClassLoaderImpl implements IClassLoader { String jarFileName = archive.getJarFile().getName(); InputStream s = null; try { - File jarFile = FileProvider.getFile(jarFileName); + File jarFile = (new FileProvider()).getFile(jarFileName); int bufferSize = 65536; s = new BufferedInputStream(new FileInputStream(jarFile), bufferSize); byte[] b = new byte[1024]; diff --git a/com.ibm.wala.core/src/com/ibm/wala/classLoader/EclipseSourceFileModule.java b/com.ibm.wala.core/src/com/ibm/wala/classLoader/EclipseSourceFileModule.java deleted file mode 100644 index 4d3f68c78..000000000 --- a/com.ibm.wala.core/src/com/ibm/wala/classLoader/EclipseSourceFileModule.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002 - 2006 IBM Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package com.ibm.wala.classLoader; - -import java.io.File; - -import org.eclipse.core.resources.IFile; - -/** - * A module which is a wrapper around a .java file - */ -public class EclipseSourceFileModule extends SourceFileModule { - - private IFile f; - - public static EclipseSourceFileModule createEclipseSourceFileModule(IFile f) { - if (f == null) { - throw new IllegalArgumentException("null f"); - } - return new EclipseSourceFileModule(f); - } - - private EclipseSourceFileModule(IFile f) { - super(new File(f.getLocation().toOSString()),f.getLocation().lastSegment()); - this.f = f; - } - public IFile getIFile() { - return f; - } - @Override - public String toString() { - return "EclipseSourceFileModule:" + getFile().toString(); - } -} diff --git a/com.ibm.wala.core/src/com/ibm/wala/client/AbstractAnalysisEngine.java b/com.ibm.wala.core/src/com/ibm/wala/client/AbstractAnalysisEngine.java index 550193e0f..701c5bb5b 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/client/AbstractAnalysisEngine.java +++ b/com.ibm.wala.core/src/com/ibm/wala/client/AbstractAnalysisEngine.java @@ -154,7 +154,7 @@ public abstract class AbstractAnalysisEngine implements AnalysisEngine { Assertions.UNREACHABLE("no j2selibs specified. You probably did not call AppAnalysisEngine.setJ2SELibrary."); } - scope = AnalysisScopeReader.readJavaScope(SYNTHETIC_J2SE_MODEL, FileProvider.getFile(getExclusionsFile()), getClass() + scope = AnalysisScopeReader.readJavaScope(SYNTHETIC_J2SE_MODEL, (new FileProvider()).getFile(getExclusionsFile()), getClass() .getClassLoader()); // add standard libraries diff --git a/com.ibm.wala.core/src/com/ibm/wala/properties/WalaProperties.java b/com.ibm.wala.core/src/com/ibm/wala/properties/WalaProperties.java index 49031fee9..b112668f6 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/properties/WalaProperties.java +++ b/com.ibm.wala.core/src/com/ibm/wala/properties/WalaProperties.java @@ -17,10 +17,6 @@ import java.net.URL; import java.util.Collection; import java.util.Properties; -import org.eclipse.core.runtime.Platform; -import org.osgi.framework.Bundle; - -import com.ibm.wala.core.plugin.CorePlugin; import com.ibm.wala.util.WalaException; import com.ibm.wala.util.debug.Assertions; import com.ibm.wala.util.io.FileProvider; @@ -174,28 +170,8 @@ public final class WalaProperties { if (url == null) { return System.getProperty("user.dir"); //$NON-NLS-1$ } else { - return new File(FileProvider.filePathFromURL(url)).getParentFile().getParentFile().getPath(); + return new File((new FileProvider()).filePathFromURL(url)).getParentFile().getParentFile().getPath(); } } - /** - * This is fragile. Use with care. - * @return a String representing the path to the wala.core plugin installation - */ - public static String getWalaCorePluginHome() { - if (CorePlugin.getDefault() == null) { - return null; - } - String install = Platform.getInstallLocation().getURL().getPath(); - Bundle b = Platform.getBundle("com.ibm.wala.core"); - String l = b.getLocation(); - if (l.startsWith("update@")) { - l = l.replace("update@", ""); - } - if (l.startsWith("reference:file:")) { - return l.replace("reference:file:",""); - } else { - return install + File.separator + l; - } - } } diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/config/AnalysisScopeReader.java b/com.ibm.wala.core/src/com/ibm/wala/util/config/AnalysisScopeReader.java index b083ee0a1..7e3e14ba8 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/config/AnalysisScopeReader.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/config/AnalysisScopeReader.java @@ -19,12 +19,9 @@ import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.jar.JarFile; -import org.eclipse.core.runtime.Plugin; - import com.ibm.wala.classLoader.BinaryDirectoryTreeModule; import com.ibm.wala.classLoader.Module; import com.ibm.wala.classLoader.SourceDirectoryTreeModule; -import com.ibm.wala.core.plugin.CorePlugin; import com.ibm.wala.ipa.callgraph.AnalysisScope; import com.ibm.wala.properties.WalaProperties; import com.ibm.wala.shrikeCT.InvalidClassFileException; @@ -40,7 +37,7 @@ public class AnalysisScopeReader { private static final ClassLoader MY_CLASSLOADER = AnalysisScopeReader.class.getClassLoader(); - private static final String BASIC_FILE = "primordial.txt"; + protected static final String BASIC_FILE = "primordial.txt"; /** * read in an analysis scope for a Java application from a text file @@ -52,20 +49,15 @@ public class AnalysisScopeReader { */ public static AnalysisScope readJavaScope(String scopeFileName, File exclusionsFile, ClassLoader javaLoader) throws IOException { AnalysisScope scope = AnalysisScope.createJavaAnalysisScope(); - return read(scope, scopeFileName, exclusionsFile, javaLoader, CorePlugin.getDefault()); + return read(scope, scopeFileName, exclusionsFile, javaLoader, new FileProvider()); } - private static AnalysisScope readJavaScope(String scopeFileName, File exclusionsFile, ClassLoader javaLoader, Plugin plugIn) throws IOException { - AnalysisScope scope = AnalysisScope.createJavaAnalysisScope(); - return read(scope, scopeFileName, exclusionsFile, javaLoader, plugIn); - } - private static AnalysisScope read(AnalysisScope scope, String scopeFileName, File exclusionsFile, ClassLoader javaLoader, - Plugin plugIn) throws IOException { + protected static AnalysisScope read(AnalysisScope scope, String scopeFileName, File exclusionsFile, ClassLoader javaLoader, + FileProvider fp) throws IOException { BufferedReader r = null; try { - File scopeFile = (plugIn == null) ? FileProvider.getFile(scopeFileName, javaLoader) : FileProvider.getFileFromPlugin(plugIn, - scopeFileName); + File scopeFile = fp.getFile(scopeFileName, javaLoader); assert scopeFile.exists(); String line; @@ -116,26 +108,27 @@ public class AnalysisScopeReader { String language = toks.nextToken(); String entryType = toks.nextToken(); String entryPathname = toks.nextToken(); + FileProvider fp = (new FileProvider()); if ("classFile".equals(entryType)) { - File cf = FileProvider.getFile(entryPathname, javaLoader); + File cf = fp.getFile(entryPathname, javaLoader); try { scope.addClassFileToScope(walaLoader, cf); } catch (InvalidClassFileException e) { Assertions.UNREACHABLE(e.toString()); } } else if ("sourceFile".equals(entryType)) { - File sf = FileProvider.getFile(entryPathname, javaLoader); + File sf = fp.getFile(entryPathname, javaLoader); scope.addSourceFileToScope(walaLoader, sf, entryPathname); } else if ("binaryDir".equals(entryType)) { - File bd = FileProvider.getFile(entryPathname, javaLoader); + File bd = fp.getFile(entryPathname, javaLoader); assert bd.isDirectory(); scope.addToScope(walaLoader, new BinaryDirectoryTreeModule(bd)); } else if ("sourceDir".equals(entryType)) { - File sd = FileProvider.getFile(entryPathname, javaLoader); + File sd = fp.getFile(entryPathname, javaLoader); assert sd.isDirectory(); scope.addToScope(walaLoader, new SourceDirectoryTreeModule(sd)); } else if ("jarFile".equals(entryType)) { - Module M = FileProvider.getJarFileModule(entryPathname, javaLoader); + Module M = fp.getJarFileModule(entryPathname, javaLoader); scope.addToScope(walaLoader, M); } else if ("loaderImpl".equals(entryType)) { scope.setLoaderImpl(walaLoader, entryPathname); @@ -155,12 +148,10 @@ public class AnalysisScopeReader { * @throws IllegalStateException if there are problmes reading wala properties */ public static AnalysisScope makePrimordialScope(File exclusionsFile) throws IOException { - return readJavaScope(BASIC_FILE, exclusionsFile, MY_CLASSLOADER, CorePlugin.getDefault()); + return readJavaScope(BASIC_FILE, exclusionsFile, MY_CLASSLOADER); } - private static AnalysisScope makePrimordialScope(File exclusionsFile, Plugin plugIn) throws IOException { - return readJavaScope(BASIC_FILE, exclusionsFile, MY_CLASSLOADER, plugIn); - } + /** * @param classPath class path to analyze, delimited by File.pathSeparator @@ -169,20 +160,10 @@ public class AnalysisScopeReader { * @throws IllegalStateException if there are problems reading wala properties */ public static AnalysisScope makeJavaBinaryAnalysisScope(String classPath, File exclusionsFile) throws IOException { - return makeJavaBinaryAnalysisScope(classPath, exclusionsFile, CorePlugin.getDefault()); - } - - /** - * @param classPath class path to analyze, delimited by File.pathSeparator - * @param exclusionsFile file holding class hierarchy exclusions. may be null - * @throws IOException - * @throws IllegalStateException if there are problems reading wala properties - */ - public static AnalysisScope makeJavaBinaryAnalysisScope(String classPath, File exclusionsFile, Plugin plugIn) throws IOException { if (classPath == null) { throw new IllegalArgumentException("classPath null"); } - AnalysisScope scope = makePrimordialScope(exclusionsFile, plugIn); + AnalysisScope scope = makePrimordialScope(exclusionsFile); ClassLoaderReference loader = scope.getLoader(AnalysisScope.APPLICATION); addClassPathToScope(classPath, scope, loader); diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/io/FileProvider.java b/com.ibm.wala.core/src/com/ibm/wala/util/io/FileProvider.java index b15a1a063..22aeabfa8 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/io/FileProvider.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/io/FileProvider.java @@ -14,240 +14,81 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import java.lang.reflect.Method; import java.net.JarURLConnection; -import java.net.MalformedURLException; import java.net.URI; import java.net.URL; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.zip.ZipException; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Plugin; - import com.ibm.wala.classLoader.JarFileModule; import com.ibm.wala.classLoader.Module; import com.ibm.wala.classLoader.NestedJarFileModule; -import com.ibm.wala.core.plugin.CorePlugin; -import com.ibm.wala.util.debug.Assertions; /** * This class provides files that are packaged with this plug-in */ public class FileProvider { - /** - * This class uses reflection to access classes and methods that are only - * available when Eclipse is running as an IDE environment. The choice to use - * reflection is related to builds: with this design the build doesn't need to - * provide IDE bundles during compilation and hence can spot invalid uses of - * such classes through this bundle. - * - * Because of this class, this bundle must OPTIONALY require - * 'org.eclipse.core.resources'. - */ - private static final class EclipseUtil { - private static Object workspaceRoot = null; - private static Method workspaceRoot_getFile = null; - - public static Module getJarFileModule(String fileName, ClassLoader loader) { - // Using reflection to enable this code to be built without the - // org.eclipse.core.resources bundle - // - try { - if (workspaceRoot_getFile == null) { - Class cls = Class.forName("org.eclipse.core.resources.ResourcesPlugin"); - Method getWorkspaceMethod = cls.getDeclaredMethod("getWorkspace"); - Object workspace = getWorkspaceMethod.invoke(null); - Method getRoot = workspace.getClass().getDeclaredMethod("getRoot"); - workspaceRoot = getRoot.invoke(workspace); - workspaceRoot_getFile = workspaceRoot.getClass().getMethod("getFile", IPath.class); - } - - IPath path = new Path(fileName); - if (workspaceRoot_getFile.invoke(workspaceRoot, path) != null) { - return new JarFileModule(new JarFile(fileName, false)); - } - } catch (Exception e) { - } - return null; - } - } private final static int DEBUG_LEVEL = 0; - - public FileProvider() { - super(); - } - + /** * @param fileName * @return the jar file packaged with this plug-in of the given name, or null * if not found. */ - public static Module getJarFileModule(String fileName) throws IOException { + public Module getJarFileModule(String fileName) throws IOException { return getJarFileModule(fileName, FileProvider.class.getClassLoader()); } - public static Module getJarFileModule(String fileName, ClassLoader loader) throws IOException { - if (CorePlugin.getDefault() == null) { - return getJarFileFromClassLoader(fileName, loader); - } else if (CorePlugin.IS_RESOURCES_BUNDLE_AVAILABLE) { - Module module = EclipseUtil.getJarFileModule(fileName, loader); - if (module != null) { - return module; - } - } - return getFromPlugin(CorePlugin.getDefault(), fileName); + public Module getJarFileModule(String fileName, ClassLoader loader) throws IOException { + return getJarFileFromClassLoader(fileName, loader); } - public static URL getResource(String fileName) throws IOException { + public URL getResource(String fileName) throws IOException { if (fileName == null) { throw new IllegalArgumentException("null fileName"); } return getResource(fileName, FileProvider.class.getClassLoader()); } - public static URL getResource(String fileName, ClassLoader loader) throws IOException { + public URL getResource(String fileName, ClassLoader loader) throws IOException { if (fileName == null) { throw new IllegalArgumentException("null fileName"); } - if (CorePlugin.getDefault() == null && loader == null) { + if (loader == null) { throw new IllegalArgumentException("null loader"); } - return (CorePlugin.getDefault() == null) ? loader.getResource(fileName) : FileLocator.find(CorePlugin.getDefault().getBundle(), - new Path(fileName), null); + return loader.getResource(fileName); } - public static File getFile(String fileName) throws IOException { + public File getFile(String fileName) throws IOException { if (fileName == null) { throw new IllegalArgumentException("null fileName"); } return getFile(fileName, FileProvider.class.getClassLoader()); } - public static File getFile(String fileName, ClassLoader loader) throws IOException { - return (CorePlugin.getDefault() == null) ? getFileFromClassLoader(fileName, loader) : getFileFromPlugin( - CorePlugin.getDefault(), fileName); - } - - /** - * @param fileName - * @return the jar file packaged with this plug-in of the given name, or null - * if not found. - * @throws IllegalArgumentException - * if p is null - */ - public static File getFileFromPlugin(Plugin p, String fileName) throws IOException { - - if (p == null) { - throw new IllegalArgumentException("p is null"); - } - if (fileName == null) { - throw new IllegalArgumentException("null fileName"); - } - URL url = getFileURLFromPlugin(p, fileName); - if (url == null) { - throw new FileNotFoundException(fileName); - } - return new File(filePathFromURL(url)); - } - - /** - * @param fileName - * @return the jar file packaged with this plug-in of the given name, or null - * if not found. - */ - private static JarFileModule getFromPlugin(Plugin p, String fileName) throws IOException { - URL url = getFileURLFromPlugin(p, fileName); - return (url == null) ? null : new JarFileModule(new JarFile(filePathFromURL(url))); - } - - /** - * get a file URL for a file from a plugin - * - * @param fileName - * the file name - * @return the URL, or null if the file is not found - * @throws IOException - */ - private static URL getFileURLFromPlugin(Plugin p, String fileName) throws IOException { - try { - URL url = FileLocator.find(p.getBundle(), new Path(fileName), null); - if (url == null) { - // try lib/fileName - String libFileName = "lib/" + fileName; - url = FileLocator.find(p.getBundle(), new Path(libFileName), null); - if (url == null) { - // try bin/fileName - String binFileName = "bin/" + fileName; - url = FileLocator.find(p.getBundle(), new Path(binFileName), null); - if (url == null) { - // try it as an absolute path? - File f = new File(fileName); - if (!f.exists()) { - // give up - return null; - } else { - url = f.toURI().toURL(); - } - } - } - } - url = FileLocator.toFileURL(url); - url = fixupFileURLSpaces(url); - return url; - } catch (ExceptionInInitializerError e) { - throw new IOException("failure to get file URL for " + fileName); - } - } - - /** - * escape spaces in a URL, primarily to work around a bug in - * {@link File#toURL()} - * - * @param url - * @return an escaped version of the URL - */ - private static URL fixupFileURLSpaces(URL url) { - String urlString = url.toExternalForm(); - StringBuffer fixedUpUrl = new StringBuffer(); - int lastIndex = 0; - while (true) { - int spaceIndex = urlString.indexOf(' ', lastIndex); - - if (spaceIndex < 0) { - fixedUpUrl.append(urlString.substring(lastIndex)); - break; - } - - fixedUpUrl.append(urlString.substring(lastIndex, spaceIndex)); - fixedUpUrl.append("%20"); - lastIndex = spaceIndex + 1; - } - try { - return new URL(fixedUpUrl.toString()); - } catch (MalformedURLException e) { - e.printStackTrace(); - Assertions.UNREACHABLE(); - } - return null; + public File getFile(String fileName, ClassLoader loader) throws IOException { + return getFileFromClassLoader(fileName, loader); } /** * @throws FileNotFoundException */ - public static File getFileFromClassLoader(String fileName, ClassLoader loader) throws FileNotFoundException { + public File getFileFromClassLoader(String fileName, ClassLoader loader) throws FileNotFoundException { if (loader == null) { throw new IllegalArgumentException("null loader"); } if (fileName == null) { throw new IllegalArgumentException("null fileName"); } - URL url = loader.getResource(fileName); + URL url = null; + try { + url = loader.getResource(fileName); + } catch (Exception e) { + } if (DEBUG_LEVEL > 0) { System.err.println(("FileProvider got url: " + url + " for " + fileName)); } @@ -267,7 +108,7 @@ public class FileProvider { /** * @throws FileNotFoundException */ - public static InputStream getInputStreamFromClassLoader(String fileName, ClassLoader loader) throws FileNotFoundException { + public InputStream getInputStreamFromClassLoader(String fileName, ClassLoader loader) throws FileNotFoundException { if (loader == null) { throw new IllegalArgumentException("null loader"); } @@ -286,7 +127,7 @@ public class FileProvider { * if not found: wrapped as a JarFileModule or a NestedJarFileModule * @throws IOException */ - public static Module getJarFileFromClassLoader(String fileName, ClassLoader loader) throws IOException { + public Module getJarFileFromClassLoader(String fileName, ClassLoader loader) throws IOException { if (fileName == null) { throw new IllegalArgumentException("null fileName"); } @@ -330,7 +171,7 @@ public class FileProvider { * @throws IllegalArgumentException * if url is null */ - public static String filePathFromURL(URL url) { + public String filePathFromURL(URL url) { if (url == null) { throw new IllegalArgumentException("url is null"); } diff --git a/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/SWTCallGraph.java b/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/SWTCallGraph.java index a68dca303..7c52cb4f0 100644 --- a/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/SWTCallGraph.java +++ b/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/SWTCallGraph.java @@ -91,7 +91,7 @@ public class SWTCallGraph { String exclusionFile = p.getProperty("exclusions"); AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(appJar, exclusionFile != null ? new File(exclusionFile) - : FileProvider.getFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS)); + : (new FileProvider()).getFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS)); ClassHierarchy cha = ClassHierarchy.make(scope); diff --git a/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/SWTPointsTo.java b/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/SWTPointsTo.java index 2d509272e..97e4dbfb1 100644 --- a/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/SWTPointsTo.java +++ b/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/SWTPointsTo.java @@ -79,7 +79,7 @@ public class SWTPointsTo { } public static Graph buildPointsTo(String appJar) throws WalaException, IllegalArgumentException, CancelException, IOException { - AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(appJar, FileProvider.getFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS)); + AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(appJar, (new FileProvider()).getFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS)); ClassHierarchy cha = ClassHierarchy.make(scope); diff --git a/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/SWTTypeHierarchy.java b/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/SWTTypeHierarchy.java index 1a7d85bd8..8a0aff161 100644 --- a/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/SWTTypeHierarchy.java +++ b/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/SWTTypeHierarchy.java @@ -54,7 +54,7 @@ public class SWTTypeHierarchy { public static ApplicationWindow run(String classpath) { try { - AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(classpath, FileProvider + AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(classpath, (new FileProvider()) .getFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS)); // invoke WALA to build a class hierarchy diff --git a/com.ibm.wala.ide/META-INF/MANIFEST.MF b/com.ibm.wala.ide/META-INF/MANIFEST.MF index 5a7538dc0..11b39d85c 100644 --- a/com.ibm.wala.ide/META-INF/MANIFEST.MF +++ b/com.ibm.wala.ide/META-INF/MANIFEST.MF @@ -4,6 +4,7 @@ Eclipse-LazyStart: true Bundle-Name: %pluginName Bundle-SymbolicName: com.ibm.wala.ide Bundle-Version: 1.1.3.qualifier +Bundle-Activator: com.ibm.wala.ide.plugin.CorePlugin Bundle-Vendor: %providerName Bundle-Localization: plugin Require-Bundle: com.ibm.wala.shrike, @@ -18,5 +19,6 @@ Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: J2SE-1.5 Export-Package: com.ibm.wala.ide, com.ibm.wala.ide.classloader, + com.ibm.wala.ide.plugin, com.ibm.wala.ide.ui, com.ibm.wala.ide.util diff --git a/com.ibm.wala.core/src/com/ibm/wala/core/plugin/CorePlugin.java b/com.ibm.wala.ide/src/com/ibm/wala/ide/plugin/CorePlugin.java similarity index 94% rename from com.ibm.wala.core/src/com/ibm/wala/core/plugin/CorePlugin.java rename to com.ibm.wala.ide/src/com/ibm/wala/ide/plugin/CorePlugin.java index 07703330a..29d013e49 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/core/plugin/CorePlugin.java +++ b/com.ibm.wala.ide/src/com/ibm/wala/ide/plugin/CorePlugin.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package com.ibm.wala.core.plugin; +package com.ibm.wala.ide.plugin; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Plugin; diff --git a/com.ibm.wala.ide/src/com/ibm/wala/ide/util/EclipseAnalysisScopeReader.java b/com.ibm.wala.ide/src/com/ibm/wala/ide/util/EclipseAnalysisScopeReader.java new file mode 100644 index 000000000..6f1e14448 --- /dev/null +++ b/com.ibm.wala.ide/src/com/ibm/wala/ide/util/EclipseAnalysisScopeReader.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package com.ibm.wala.ide.util; + +import java.io.File; +import java.io.IOException; + +import org.eclipse.core.runtime.Plugin; + +import com.ibm.wala.ide.plugin.CorePlugin; +import com.ibm.wala.ipa.callgraph.AnalysisScope; +import com.ibm.wala.types.ClassLoaderReference; +import com.ibm.wala.util.config.AnalysisScopeReader; + +public class EclipseAnalysisScopeReader extends AnalysisScopeReader { + + public static AnalysisScope readJavaScopeFromPlugin(String scopeFileName, File exclusionsFile, ClassLoader javaLoader) throws IOException { + return readJavaScopeFromPlugin(scopeFileName, exclusionsFile, javaLoader, CorePlugin.getDefault()); + } + public static AnalysisScope readJavaScopeFromPlugin(String scopeFileName, File exclusionsFile, ClassLoader javaLoader, Plugin plugIn) throws IOException { + AnalysisScope scope = AnalysisScope.createJavaAnalysisScope(); + return read(scope, scopeFileName, exclusionsFile, javaLoader, new EclipseFileProvider(plugIn)); + } + + public static AnalysisScope makePrimordialScopeFromPlugin(File exclusionsFile) throws IOException { + return makePrimordialScopeFromPlugin(exclusionsFile, CorePlugin.getDefault()); + } + /** + * @param exclusionsFile file holding class hierarchy exclusions. may be null + * @throws IOException + * @throws IllegalStateException if there are problmes reading wala properties + */ + public static AnalysisScope makePrimordialScopeFromPlugin(File exclusionsFile, Plugin plugIn) throws IOException { + return read(AnalysisScope.createJavaAnalysisScope(), BASIC_FILE, exclusionsFile, + EclipseAnalysisScopeReader.class.getClassLoader(), new EclipseFileProvider(plugIn)); + } + + public static AnalysisScope makeJavaBinaryAnalysisScopeFromPlugin(String classPath, File exclusionsFile) throws IOException { + return makeJavaBinaryAnalysisScopeFromPlugin(classPath, exclusionsFile, CorePlugin.getDefault()); + } + + /** + * @param classPath class path to analyze, delimited by File.pathSeparator + * @param exclusionsFile file holding class hierarchy exclusions. may be null + * @throws IOException + * @throws IllegalStateException if there are problems reading wala properties + */ + public static AnalysisScope makeJavaBinaryAnalysisScopeFromPlugin(String classPath, File exclusionsFile, Plugin plugIn) throws IOException { + if (classPath == null) { + throw new IllegalArgumentException("classPath null"); + } + AnalysisScope scope = makePrimordialScopeFromPlugin(exclusionsFile, plugIn); + ClassLoaderReference loader = scope.getLoader(AnalysisScope.APPLICATION); + + addClassPathToScope(classPath, scope, loader); + + return scope; + } +} diff --git a/com.ibm.wala.ide/src/com/ibm/wala/ide/util/EclipseFileProvider.java b/com.ibm.wala.ide/src/com/ibm/wala/ide/util/EclipseFileProvider.java new file mode 100644 index 000000000..dffbbac8f --- /dev/null +++ b/com.ibm.wala.ide/src/com/ibm/wala/ide/util/EclipseFileProvider.java @@ -0,0 +1,245 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package com.ibm.wala.ide.util; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.jar.JarFile; + +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Plugin; +import org.osgi.framework.Bundle; + +import com.ibm.wala.classLoader.JarFileModule; +import com.ibm.wala.classLoader.Module; +import com.ibm.wala.ide.plugin.CorePlugin; +import com.ibm.wala.util.debug.Assertions; +import com.ibm.wala.util.io.FileProvider; + +public class EclipseFileProvider extends FileProvider { + + /** + * the plug-in to use. If null, {@link CorePlugin#getDefault()} is used. + */ + private final Plugin plugIn; + + public EclipseFileProvider() { + this(null); + } + + public EclipseFileProvider(Plugin plugIn) { + this.plugIn = plugIn; + } + /** + * This class uses reflection to access classes and methods that are only + * available when Eclipse is running as an IDE environment. The choice to use + * reflection is related to builds: with this design the build doesn't need to + * provide IDE bundles during compilation and hence can spot invalid uses of + * such classes through this bundle. + * + * Because of this class, this bundle must OPTIONALY require + * 'org.eclipse.core.resources'. + */ + private static final class EclipseUtil { + private static Object workspaceRoot = null; + private static Method workspaceRoot_getFile = null; + + public static Module getJarFileModule(String fileName) { + // Using reflection to enable this code to be built without the + // org.eclipse.core.resources bundle + // + try { + if (workspaceRoot_getFile == null) { + Class cls = Class.forName("org.eclipse.core.resources.ResourcesPlugin"); + Method getWorkspaceMethod = cls.getDeclaredMethod("getWorkspace"); + Object workspace = getWorkspaceMethod.invoke(null); + Method getRoot = workspace.getClass().getDeclaredMethod("getRoot"); + workspaceRoot = getRoot.invoke(workspace); + workspaceRoot_getFile = workspaceRoot.getClass().getMethod("getFile", IPath.class); + } + + IPath path = new Path(fileName); + if (workspaceRoot_getFile.invoke(workspaceRoot, path) != null) { + return new JarFileModule(new JarFile(fileName, false)); + } + } catch (Exception e) { + } + return null; + } + } + + @Override + public Module getJarFileModule(String fileName, ClassLoader loader) throws IOException { + if (CorePlugin.getDefault() == null) { + return getJarFileFromClassLoader(fileName, loader); + } else if (plugIn != null) { + return getFromPlugin(plugIn, fileName); + } else if (CorePlugin.IS_RESOURCES_BUNDLE_AVAILABLE) { + Module module = EclipseUtil.getJarFileModule(fileName); + if (module != null) { + return module; + } + } + return getFromPlugin(CorePlugin.getDefault(), fileName); + } + + /** + * @param fileName + * @return the jar file packaged with this plug-in of the given name, or null + * if not found. + */ + private JarFileModule getFromPlugin(Plugin p, String fileName) throws IOException { + URL url = getFileURLFromPlugin(p, fileName); + return (url == null) ? null : new JarFileModule(new JarFile(filePathFromURL(url))); + } + + /** + * get a file URL for a file from a plugin + * + * @param fileName + * the file name + * @return the URL, or null if the file is not found + * @throws IOException + */ + private URL getFileURLFromPlugin(Plugin p, String fileName) throws IOException { + try { + URL url = FileLocator.find(p.getBundle(), new Path(fileName), null); + if (url == null) { + // try lib/fileName + String libFileName = "lib/" + fileName; + url = FileLocator.find(p.getBundle(), new Path(libFileName), null); + if (url == null) { + // try bin/fileName + String binFileName = "bin/" + fileName; + url = FileLocator.find(p.getBundle(), new Path(binFileName), null); + if (url == null) { + // try it as an absolute path? + File f = new File(fileName); + if (!f.exists()) { + // give up + return null; + } else { + url = f.toURI().toURL(); + } + } + } + } + url = FileLocator.toFileURL(url); + url = fixupFileURLSpaces(url); + return url; + } catch (ExceptionInInitializerError e) { + throw new IOException("failure to get file URL for " + fileName); + } + } + + /** + * escape spaces in a URL, primarily to work around a bug in + * {@link File#toURL()} + * + * @param url + * @return an escaped version of the URL + */ + private URL fixupFileURLSpaces(URL url) { + String urlString = url.toExternalForm(); + StringBuffer fixedUpUrl = new StringBuffer(); + int lastIndex = 0; + while (true) { + int spaceIndex = urlString.indexOf(' ', lastIndex); + + if (spaceIndex < 0) { + fixedUpUrl.append(urlString.substring(lastIndex)); + break; + } + + fixedUpUrl.append(urlString.substring(lastIndex, spaceIndex)); + fixedUpUrl.append("%20"); + lastIndex = spaceIndex + 1; + } + try { + return new URL(fixedUpUrl.toString()); + } catch (MalformedURLException e) { + e.printStackTrace(); + Assertions.UNREACHABLE(); + } + return null; + } + + @Override + public URL getResource(String fileName, ClassLoader loader) throws IOException { + if (fileName == null) { + throw new IllegalArgumentException("null fileName"); + } + Plugin p = plugIn == null ? CorePlugin.getDefault() : plugIn; + if (p == null && loader == null) { + throw new IllegalArgumentException("null loader"); + } + return (p == null) ? loader.getResource(fileName) : FileLocator.find(p.getBundle(), + new Path(fileName), null); + } + + @Override + public File getFile(String fileName, ClassLoader loader) throws IOException { + Plugin p = plugIn == null ? CorePlugin.getDefault() : plugIn; + return (p == null) ? getFileFromClassLoader(fileName, loader) : getFileFromPlugin( + p, fileName); + } + + /** + * @param fileName + * @return the jar file packaged with this plug-in of the given name, or null + * if not found. + * @throws IllegalArgumentException + * if p is null + */ + public File getFileFromPlugin(Plugin p, String fileName) throws IOException { + + if (p == null) { + throw new IllegalArgumentException("p is null"); + } + if (fileName == null) { + throw new IllegalArgumentException("null fileName"); + } + URL url = getFileURLFromPlugin(p, fileName); + if (url == null) { + throw new FileNotFoundException(fileName); + } + return new File(filePathFromURL(url)); + } + + /** + * This is fragile. Use with care. + * @return a String representing the path to the wala.core plugin installation + */ + public static String getWalaCorePluginHome() { + if (CorePlugin.getDefault() == null) { + return null; + } + String install = Platform.getInstallLocation().getURL().getPath(); + Bundle b = Platform.getBundle("com.ibm.wala.core"); + String l = b.getLocation(); + if (l.startsWith("update@")) { + l = l.replace("update@", ""); + } + if (l.startsWith("reference:file:")) { + return l.replace("reference:file:",""); + } else { + return install + File.separator + l; + } + } + +} diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/ProgressMaster.java b/com.ibm.wala.ide/src/com/ibm/wala/ide/util/ProgressMaster.java similarity index 95% rename from com.ibm.wala.core/src/com/ibm/wala/util/ProgressMaster.java rename to com.ibm.wala.ide/src/com/ibm/wala/ide/util/ProgressMaster.java index edf169dd5..de3b85968 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/ProgressMaster.java +++ b/com.ibm.wala.ide/src/com/ibm/wala/ide/util/ProgressMaster.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package com.ibm.wala.util; +package com.ibm.wala.ide.util; import org.eclipse.core.runtime.IProgressMonitor; diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/ProgressMonitorDelegate.java b/com.ibm.wala.ide/src/com/ibm/wala/ide/util/ProgressMonitorDelegate.java similarity index 96% rename from com.ibm.wala.core/src/com/ibm/wala/util/ProgressMonitorDelegate.java rename to com.ibm.wala.ide/src/com/ibm/wala/ide/util/ProgressMonitorDelegate.java index c30b00a2c..1a6073e76 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/ProgressMonitorDelegate.java +++ b/com.ibm.wala.ide/src/com/ibm/wala/ide/util/ProgressMonitorDelegate.java @@ -8,8 +8,9 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package com.ibm.wala.util; +package com.ibm.wala.ide.util; +import com.ibm.wala.util.MonitorUtil; import com.ibm.wala.util.MonitorUtil.IProgressMonitor; /** diff --git a/com.ibm.wala.j2ee/src/com/ibm/wala/j2ee/J2EEAnalysisScope.java b/com.ibm.wala.j2ee/src/com/ibm/wala/j2ee/J2EEAnalysisScope.java index c5d1b07be..4ec89e1a1 100644 --- a/com.ibm.wala.j2ee/src/com/ibm/wala/j2ee/J2EEAnalysisScope.java +++ b/com.ibm.wala.j2ee/src/com/ibm/wala/j2ee/J2EEAnalysisScope.java @@ -48,7 +48,7 @@ public class J2EEAnalysisScope extends AnalysisScope { * @param lifecycleEntrypoints Should EJB lifecycle entrypoints be considered as call graph entrypoints? */ public J2EEAnalysisScope(String baseScope, ClassLoader loader, boolean lifecycleEntrypoints) throws IOException { - this(baseScope, loader, FileProvider.getFile(EXCLUSIONS_FILE), lifecycleEntrypoints); + this(baseScope, loader, (new FileProvider()).getFile(EXCLUSIONS_FILE), lifecycleEntrypoints); } /**