diff -Nru "/tmp/tmpdO65hx/hoNCbJkA_9/wala-1.3.9/After Importing WALA Into Eclipse.launch" "/tmp/tmpdO65hx/vj4dUdzt1P/wala-1.5.1/After Importing WALA Into Eclipse.launch" --- "/tmp/tmpdO65hx/hoNCbJkA_9/wala-1.3.9/After Importing WALA Into Eclipse.launch" 1970-01-01 00:00:00.000000000 +0000 +++ "/tmp/tmpdO65hx/vj4dUdzt1P/wala-1.5.1/After Importing WALA Into Eclipse.launch" 2019-01-29 17:08:39.000000000 +0000 @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff -Nru wala-1.3.9/appveyor.yml.disabled wala-1.5.1/appveyor.yml.disabled --- wala-1.3.9/appveyor.yml.disabled 1970-01-01 00:00:00.000000000 +0000 +++ wala-1.5.1/appveyor.yml.disabled 2019-01-29 17:08:39.000000000 +0000 @@ -0,0 +1,25 @@ +os: Visual Studio 2015 + +install: + - ps: | + Add-Type -AssemblyName System.IO.Compression.FileSystem + if (!(Test-Path -Path "C:\maven" )) { + (new-object System.Net.WebClient).DownloadFile( + 'http://www.us.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.zip', + 'C:\maven-bin.zip' + ) + [System.IO.Compression.ZipFile]::ExtractToDirectory("C:\maven-bin.zip", "C:\maven") + } + - cmd: SET PATH=C:\maven\apache-maven-3.3.9\bin;%JAVA_HOME%\bin;%PATH% + - cmd: SET MAVEN_OPTS=-XX:MaxPermSize=2g -Xmx4g + - cmd: SET JAVA_OPTS=-XX:MaxPermSize=2g -Xmx4g + +build_script: + - mvn clean verify -DskipTests=true -B -q + +test_script: + - mvn clean verify -B -q + +cache: + - C:\maven\ + - C:\Users\appveyor\.m2 \ No newline at end of file diff -Nru wala-1.3.9/build.gradle wala-1.5.1/build.gradle --- wala-1.3.9/build.gradle 1970-01-01 00:00:00.000000000 +0000 +++ wala-1.5.1/build.gradle 2019-01-29 17:08:39.000000000 +0000 @@ -0,0 +1,186 @@ +//////////////////////////////////////////////////////////////////////// +// +// plugin configuration must precede everything else +// + +plugins { + id 'com.diffplug.gradle.p2.asmaven' version '3.17.0' + id 'com.github.hauner.jarTest' version '1.0.1' apply false + id 'de.undercouch.download' + id 'nebula.lint' version '8.3.1' + id 'nebula.source-jar' version '7.0.1' apply false + id 'maven-publish' +} + + +//////////////////////////////////////////////////////////////////////// +// +// required Eclipse components +// + +p2AsMaven { + group 'eclipse-deps', { + repoEclipse '4.7.2' + slicingOption 'latestVersionOnly', 'true' + iu 'org.eclipse.core.commands' + iu 'org.eclipse.core.contenttype' + iu 'org.eclipse.core.jobs' + iu 'org.eclipse.core.resources' + iu 'org.eclipse.core.runtime' + iu 'org.eclipse.equinox.app' + iu 'org.eclipse.equinox.common' + iu 'org.eclipse.equinox.preferences' + iu 'org.eclipse.jdt.core' + iu 'org.eclipse.jface' + iu 'org.eclipse.osgi' + iu 'org.eclipse.pde.core' + iu 'org.eclipse.swt' + iu 'org.eclipse.ui.ide' + iu 'org.eclipse.ui.workbench' + } + group 'wst-deps', { + repo 'http://download.eclipse.org/releases/oxygen' + slicingOption 'latestVersionOnly', 'true' + iu 'org.eclipse.wst.jsdt.core' + iu 'org.eclipse.wst.jsdt.ui' + } +} + + +//////////////////////////////////////////////////////////////////////// +// +// common Java setup shared by multiple projects +// + +group name +version '1.5.1' + +subprojects { subproject -> + // skip generic Java setup for the few projects that have no Java code whatsoever + switch (subproject.name) { + case 'com.ibm.wala-repository': + case ~/.*_feature/: + return + } + + apply plugin: 'java' + apply plugin: 'maven-publish' + apply plugin: 'nebula.source-jar' + + version rootProject.version + + repositories { + mavenCentral() + maven { + url "$rootProject.buildDir/p2asmaven/maven" + } + } + + jar.manifest.from('META-INF/MANIFEST.MF') + + publishing.publications { + mavenJava(MavenPublication) { + from components.java + } + } + + task afterEclipseBuildshipImport(dependsOn: processTestResources) + task prepareIntelliJIDEA + + test { + include '**/*Test.class' + include '**/*TestCase.class' + include '**/*Tests.class' + include '**/Test*.class' + exclude '**/*AndroidLibs*.class' + + maxParallelForks = Integer.MAX_VALUE + } +} + +task afterEclipseBuildshipImport(type: Exec) { + commandLine './revert-launchers.sh' +} + + +//////////////////////////////////////////////////////////////////////// +// +// find platform-specific SWT implementations +// + +def osgi_platform + +switch (System.getProperty('os.name')) { + case ~/Mac OS X/: + osgi_platform = 'cocoa.macosx.x86_64' + break + case ~/Windows.*/: + osgi_platform = 'win32.win32.x86_64' + break + case ~/Linux/: + osgi_platform = 'gtk.linux.x86_64' + break +} + +System.setProperty('osgi.platform', osgi_platform) + +subprojects { + configurations.all { + resolutionStrategy { + // failOnVersionConflict() + dependencySubstitution { + substitute module('eclipse-deps:org.eclipse.swt.${osgi.platform}') with module("eclipse-deps:org.eclipse.swt.${System.getProperty('osgi.platform')}:3.+") + } + } + } +} + + +//////////////////////////////////////////////////////////////////////// +// +// optional lint checking of Gradle scripts +// + +allprojects { + apply plugin: 'nebula.lint' + gradleLint.alwaysRun = false + gradleLint { + rules = ['all-dependency'] + excludedRules = [ + 'duplicate-dependency-class', + 'transitive-duplicate-dependency-class', + 'unused-dependency', + ] + } +} + + +//////////////////////////////////////////////////////////////////////// +// +// disable Javadoc linter until documentation is in better shape +// + +allprojects { + tasks.withType(Javadoc) { + options.addBooleanOption('Xdoclint:all,-missing', true) + options.quiet() + } +} + + +//////////////////////////////////////////////////////////////////////// +// +// Eclipse IDE integration +// + +// workaround for +allprojects { + apply plugin: 'eclipse' + + eclipse.classpath.file.whenMerged { + entries.each { + if (it in org.gradle.plugins.ide.eclipse.model.AbstractClasspathEntry && it.entryAttributes['gradle_used_by_scope'] == 'test') + it.entryAttributes['test'] = true + } + } +} diff -Nru wala-1.3.9/build-maven-jars.py wala-1.5.1/build-maven-jars.py --- wala-1.3.9/build-maven-jars.py 1970-01-01 00:00:00.000000000 +0000 +++ wala-1.5.1/build-maven-jars.py 2019-01-29 17:08:39.000000000 +0000 @@ -0,0 +1,42 @@ +#!/usr/bin/env python + +# script to build jars for maven central +import sys +import subprocess +import os + +# action should be either 'install' (for local test) +# or 'deploy' (for deployment to maven central). +# if current version is SNAPSHOT, will only be deployed +# to sonatype's staging servers. otherwise, will be +# deployed to maven central +action = sys.argv[1] + +# projects for which we should build jars, in order +# will be prefixed with 'com.ibm.wala.' +projects = [ + "util", + "shrike", + "core", + "cast", + "cast.java", + "cast.java.ecj", + "cast.js", + "cast.js.rhino", + "dalvik", + "scandroid" + ] + +for proj in projects: + full_proj = "com.ibm.wala." + proj + print(full_proj) + os.chdir(full_proj) + mvnCmd = "mvn -f mvncentral.xml clean " + action + try: + subprocess.check_output(mvnCmd, shell=True) + except subprocess.CalledProcessError as e: + print("OUTPUT") + print(e.output) + raise + os.chdir("..") + diff -Nru wala-1.3.9/buildSrc/build.gradle wala-1.5.1/buildSrc/build.gradle --- wala-1.3.9/buildSrc/build.gradle 1970-01-01 00:00:00.000000000 +0000 +++ wala-1.5.1/buildSrc/build.gradle 2019-01-29 17:08:39.000000000 +0000 @@ -0,0 +1,7 @@ +repositories { + mavenCentral() +} + +dependencies { + compile 'de.undercouch:gradle-download-task:3.4.3' +} diff -Nru wala-1.3.9/buildSrc/.gitignore wala-1.5.1/buildSrc/.gitignore --- wala-1.3.9/buildSrc/.gitignore 1970-01-01 00:00:00.000000000 +0000 +++ wala-1.5.1/buildSrc/.gitignore 2019-01-29 17:08:39.000000000 +0000 @@ -0,0 +1 @@ +/.gradle/ diff -Nru wala-1.3.9/buildSrc/src/main/groovy/package-list.groovy wala-1.5.1/buildSrc/src/main/groovy/package-list.groovy --- wala-1.3.9/buildSrc/src/main/groovy/package-list.groovy 1970-01-01 00:00:00.000000000 +0000 +++ wala-1.5.1/buildSrc/src/main/groovy/package-list.groovy 2019-01-29 17:08:39.000000000 +0000 @@ -0,0 +1,31 @@ +import org.gradle.api.tasks.* + + +//////////////////////////////////////////////////////////////////////// +// +// create a Javadoc-style "package-list" file +// + +@CacheableTask +class CreatePackageList extends org.gradle.api.DefaultTask { + + @PathSensitive(PathSensitivity.RELATIVE) + @Input Object sourceSet + + @OutputFile File packageList = new File("$temporaryDir/package-list") + + @TaskAction + def create() { + sourceSet.sourceCollections.collect { collection -> + def sourceRoot = collection.tree.dir.toPath() + collection.collect { source -> + def javaSourceFilePath = source.toPath() + def parentPath = javaSourceFilePath.parent + def relativePath = sourceRoot.relativize(parentPath) + relativePath.toString().replace(File.separator, '.') + } + }.flatten().sort().unique().each { + packageList << "$it\n" + } + } +} diff -Nru wala-1.3.9/buildSrc/src/main/groovy/verified-download.groovy wala-1.5.1/buildSrc/src/main/groovy/verified-download.groovy --- wala-1.3.9/buildSrc/src/main/groovy/verified-download.groovy 1970-01-01 00:00:00.000000000 +0000 +++ wala-1.5.1/buildSrc/src/main/groovy/verified-download.groovy 2019-01-29 17:08:39.000000000 +0000 @@ -0,0 +1,53 @@ +import org.gradle.api.tasks.* + + +//////////////////////////////////////////////////////////////////////// +// +// download and use checksum to verify that we got what we expected +// + +@CacheableTask +class VerifiedDownload extends org.gradle.api.DefaultTask { + + // URL of resource to download + def @Input src + + // expected checksum of resource as hex digits + def @Input checksum + + // algorithm to use for computing checksum + def @Input algorithm = 'MD5' + + // whether to use ETag for selective downloading + def @Input useETag = true + + // local file into which resource should be saved + def @OutputFile dest + + File getDest() { + return project.file(dest) + } + + VerifiedDownload() { + outputs.upToDateWhen { + getDest().exists() + } + } + + @TaskAction + downloadAndVerify() { + def destFile = getDest() + project.download { + src this.src + dest destFile + overwrite true + onlyIfModified true + useETag this.useETag + } + project.verifyChecksum { + src destFile + algorithm this.algorithm + checksum this.checksum + } + } +} diff -Nru wala-1.3.9/change-version.py wala-1.5.1/change-version.py --- wala-1.3.9/change-version.py 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/change-version.py 2019-01-29 17:08:39.000000000 +0000 @@ -5,6 +5,10 @@ import sys import subprocess +def runAndPrint(cmd): + print cmd + subprocess.check_output(cmd, shell=True) + oldVersion = sys.argv[1] newVersion = sys.argv[2] @@ -13,13 +17,11 @@ oldVersion = oldVersion.replace(".", "\.") newVersion = newVersion.replace(".", "\.") -cleanCmd = "mvn clean -q" -print cleanCmd -subprocess.check_output(cleanCmd, shell=True) - -xmlCmd = "find -E ./ -regex \".*(pom|mvncentral)\.xml\" | xargs -n 1 perl -pi -e \'s/" + oldVersion + "/" + newVersion + "/g\'" -print xmlCmd -subprocess.check_output(xmlCmd, shell=True) +runAndPrint("mvn clean -q") + +runAndPrint("find -E ./ -regex \".*(pom|mvncentral)\.xml\" | xargs -n 1 perl -pi -e \'s/" + oldVersion + "/" + newVersion + "/g\'") + +runAndPrint("perl -pi -e \'s/" + oldVersion + "/" + newVersion + "/g\' build.gradle") oldIsSnapshot = oldVersion.endswith("SNAPSHOT") newIsSnapShot = newVersion.endswith("SNAPSHOT") @@ -27,10 +29,7 @@ bundleOld = oldVersion if not oldIsSnapshot else oldVersion.replace("-SNAPSHOT","\.qualifier") bundleNew = newVersion if not newIsSnapShot else newVersion.replace("-SNAPSHOT","\.qualifier") -otherCmd = "find -E ./ -regex \".*(MANIFEST\.MF|feature\.xml)\" | xargs -n 1 perl -pi -e \'s/" + bundleOld + "/" + bundleNew + "/g\'" - -print otherCmd -subprocess.check_output(otherCmd, shell=True) +runAndPrint("find -E ./ -regex \".*(MANIFEST\.MF|feature\.xml)\" | xargs -n 1 perl -pi -e \'s/" + bundleOld + "/" + bundleNew + "/g\'") print "done" diff -Nru wala-1.3.9/com.ibm.wala.cast/build.gradle wala-1.5.1/com.ibm.wala.cast/build.gradle --- wala-1.3.9/com.ibm.wala.cast/build.gradle 1970-01-01 00:00:00.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/build.gradle 2019-01-29 17:08:39.000000000 +0000 @@ -0,0 +1,106 @@ +plugins { + id 'cpp' + id 'eclipse' +} + +eclipse.project.natures 'org.eclipse.pde.PluginNature' + +sourceSets.main.java.srcDirs = ['source/java'] + +dependencies { + compile( + 'commons-io:commons-io:2.4', + project(':com.ibm.wala.core'), + project(':com.ibm.wala.shrike'), + project(':com.ibm.wala.util'), + ) +} + +javadoc { + def js = ':com.ibm.wala.cast.js' + evaluationDependsOn(js) + + dependsOn "$js:compileJava" + js = project(js) + doFirst { + classpath += files js.compileJava + } + + dependsOn js.createPackageList + options.linksOffline js.javadoc.outputDirectory.path, js.createPackageList.packageList.parent +} + +def currentJavaHome = org.gradle.internal.jvm.Jvm.current().javaHome + +model { + repositories { + libs(PrebuiltLibraries) { + jdk { + def jniIncludeDir = "$currentJavaHome/include" + headers.srcDir jniIncludeDir + binaries.withType(SharedLibraryBinary) { + switch (targetPlatform.operatingSystem.name) { + case 'linux': + headers.srcDirs "$jniIncludeDir/linux" + def subdirs = ['jre/lib/amd64/server', 'lib/amd64/server', 'lib/server'] + def candidates = subdirs.collect { file("$currentJavaHome/$it/libjvm.so") } + sharedLibraryLinkFile = candidates.find { it.exists() } + break + case 'osx': + headers.srcDirs "$jniIncludeDir/darwin" + sharedLibraryLinkFile = file("$currentJavaHome/jre/lib/server/libjvm.dylib") + break + case 'windows': + headers.srcDirs "$jniIncludeDir/win32" + sharedLibraryLinkFile = file("$currentJavaHome/lib/jvm.lib") + break + } + } + } + } + } + + components { + cast(NativeLibrarySpec) { + sources.cpp { + def cSourceDir = 'source/c' + source { + srcDirs = ["$cSourceDir/jni"] + include '*.cpp' + } + exportedHeaders.srcDirs = ["$cSourceDir/include"] + lib library: 'jdk' + } + + binaries { + withType(StaticLibraryBinarySpec) { + buildable = false + } + withType(SharedLibraryBinarySpec) { + def libDir = $.repositories['libs'].resolveLibrary('jdk') + .binaries.withType(SharedLibraryBinary) + .find { it.targetPlatform.name == targetPlatform.name } + .sharedLibraryLinkFile.parent + linker.args "-Wl,-rpath,$libDir" + if (targetPlatform.operatingSystem.name == 'osx') { + linker.args "-Wl,-install_name,@rpath/$sharedLibraryFile.name" + } + } + } + } + } +} + +// TODO: if we eventually stop supporting Maven, then we may be able +// to discard the "copyJarsIntoLib" task and the corresponding lines +// in "META-INF/MANIFEST.MF" and "build.properties" + +task copyJarsIntoLib(type: Sync) { + def commonsIoJar = configurations.runtimeClasspath.files[0] + assert commonsIoJar.name.startsWith('commons-io-') + from commonsIoJar + into 'lib' +} + +assemble.dependsOn copyJarsIntoLib +clean.dependsOn cleanCopyJarsIntoLib diff -Nru wala-1.3.9/com.ibm.wala.cast/build.properties wala-1.5.1/com.ibm.wala.cast/build.properties --- wala-1.3.9/com.ibm.wala.cast/build.properties 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/build.properties 2019-01-29 17:08:39.000000000 +0000 @@ -1,5 +1,7 @@ source.. = source/java/ -output.. = bin/ +output.. = bin/main bin.includes = META-INF/,\ - lib/commons-io-2.4.jar,\ - . + lib/commons-io-2.4.jar,\ + .,\ + OSGI-INF/ +javacProjectSettings = true diff -Nru wala-1.3.9/com.ibm.wala.cast/build.xml wala-1.5.1/com.ibm.wala.cast/build.xml --- wala-1.3.9/com.ibm.wala.cast/build.xml 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/build.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -Nru wala-1.3.9/com.ibm.wala.cast/.classpath wala-1.5.1/com.ibm.wala.cast/.classpath --- wala-1.3.9/com.ibm.wala.cast/.classpath 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/.classpath 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ - - - - - - - - diff -Nru wala-1.3.9/com.ibm.wala.cast/.cvsignore wala-1.5.1/com.ibm.wala.cast/.cvsignore --- wala-1.3.9/com.ibm.wala.cast/.cvsignore 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/.cvsignore 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -bin -domo-trace.txt* diff -Nru "/tmp/tmpdO65hx/hoNCbJkA_9/wala-1.3.9/com.ibm.wala.cast/.externalToolBuilders/make WALA.CAst.launch" "/tmp/tmpdO65hx/vj4dUdzt1P/wala-1.5.1/com.ibm.wala.cast/.externalToolBuilders/make WALA.CAst.launch" --- "/tmp/tmpdO65hx/hoNCbJkA_9/wala-1.3.9/com.ibm.wala.cast/.externalToolBuilders/make WALA.CAst.launch" 2016-05-10 12:59:26.000000000 +0000 +++ "/tmp/tmpdO65hx/vj4dUdzt1P/wala-1.5.1/com.ibm.wala.cast/.externalToolBuilders/make WALA.CAst.launch" 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ - - - - - - - - - - - diff -Nru wala-1.3.9/com.ibm.wala.cast/META-INF/MANIFEST.MF wala-1.5.1/com.ibm.wala.cast/META-INF/MANIFEST.MF --- wala-1.3.9/com.ibm.wala.cast/META-INF/MANIFEST.MF 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/META-INF/MANIFEST.MF 2019-01-29 17:08:39.000000000 +0000 @@ -1,9 +1,9 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: WALA CAst core Plug-in +Bundle-Name: %Bundle-Name Bundle-SymbolicName: com.ibm.wala.cast -Bundle-Version: 1.3.9 -Bundle-Vendor: IBM +Bundle-Version: 1.5.1 +Bundle-Vendor: %Bundle-Vendor Require-Bundle: com.ibm.wala.core, com.ibm.wala.shrike Bundle-ActivationPolicy: lazy @@ -28,5 +28,6 @@ com.ibm.wala.cast.util, org.apache.commons.io, org.apache.commons.io.input -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Automatic-Module-Name: com.ibm.wala.cast diff -Nru wala-1.3.9/com.ibm.wala.cast/mvncentral.xml wala-1.5.1/com.ibm.wala.cast/mvncentral.xml --- wala-1.3.9/com.ibm.wala.cast/mvncentral.xml 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/mvncentral.xml 2019-01-29 17:08:39.000000000 +0000 @@ -5,7 +5,7 @@ 4.0.0 com.ibm.wala com.ibm.wala.cast - 1.3.9 + 1.5.1 jar WALA CAst WALA Common AST core library @@ -44,13 +44,18 @@ com.ibm.wala + com.ibm.wala.util + 1.5.1 + + + com.ibm.wala com.ibm.wala.core - 1.3.9 + 1.5.1 com.ibm.wala com.ibm.wala.shrike - 1.3.9 + 1.5.1 commons-io @@ -65,6 +70,18 @@ https://oss.sonatype.org/content/repositories/snapshots/ + + + + jdk18 + + 1.8 + + + -Xdoclint:none + + + ${src.dir} @@ -74,8 +91,8 @@ maven-compiler-plugin 3.2 - 1.7 - 1.7 + 1.8 + 1.8 @@ -107,6 +124,9 @@ org.apache.maven.plugins maven-javadoc-plugin + + ${javadoc.options} + 2.9.1 diff -Nru wala-1.3.9/com.ibm.wala.cast/OSGI-INF/l10n/bundle.properties wala-1.5.1/com.ibm.wala.cast/OSGI-INF/l10n/bundle.properties --- wala-1.3.9/com.ibm.wala.cast/OSGI-INF/l10n/bundle.properties 1970-01-01 00:00:00.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/OSGI-INF/l10n/bundle.properties 2019-01-29 17:08:39.000000000 +0000 @@ -0,0 +1,3 @@ +#Properties file for com.ibm.wala.cast +Bundle-Vendor = IBM +Bundle-Name = WALA CAst core Plug-in \ No newline at end of file diff -Nru wala-1.3.9/com.ibm.wala.cast/pom.xml wala-1.5.1/com.ibm.wala.cast/pom.xml --- wala-1.3.9/com.ibm.wala.cast/pom.xml 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/pom.xml 2019-01-29 17:08:39.000000000 +0000 @@ -5,12 +5,32 @@ WALA com.ibm.wala - 1.3.9 + 1.5.1 com.ibm.wala.cast eclipse-plugin - + + + org.codehaus.mojo + exec-maven-plugin + 1.6.0 + + + compile + + bash + + ${basedir}/source/c/cbuild.sh + + ${basedir}/source/c + + + exec + + + + maven-dependency-plugin diff -Nru wala-1.3.9/com.ibm.wala.cast/.project wala-1.5.1/com.ibm.wala.cast/.project --- wala-1.3.9/com.ibm.wala.cast/.project 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/.project 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ - - - com.ibm.wala.cast - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/make WALA.CAst.launch - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff -Nru wala-1.3.9/com.ibm.wala.cast/.settings/org.eclipse.jdt.core.prefs wala-1.5.1/com.ibm.wala.cast/.settings/org.eclipse.jdt.core.prefs --- wala-1.3.9/com.ibm.wala.cast/.settings/org.eclipse.jdt.core.prefs 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/.settings/org.eclipse.jdt.core.prefs 2019-01-29 17:08:39.000000000 +0000 @@ -1,78 +1,126 @@ eclipse.preferences.version=1 instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=enabled +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullable.secondary= +org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.doc.comment.support=enabled -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=error +org.eclipse.jdt.core.compiler.problem.deadCode=error org.eclipse.jdt.core.compiler.problem.deprecation=warning org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.discouragedReference=error +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=error +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore -org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.finalParameterBound=error +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=error -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning -org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=error +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=error +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=error +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=error org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=error +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=error +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=all_standard_tags org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=error +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=error +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore -org.eclipse.jdt.core.compiler.problem.nullReference=warning -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=error +org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=error +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=warning +org.eclipse.jdt.core.compiler.problem.nullReference=error +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=warning +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=error +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning -org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=error +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=error +org.eclipse.jdt.core.compiler.problem.rawTypeReference=error +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=error +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=error +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=error +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=error +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=error org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=enabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=error +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=error +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled +org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=error org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.unusedImport=warning -org.eclipse.jdt.core.compiler.problem.unusedLabel=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=warning -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedImport=error +org.eclipse.jdt.core.compiler.problem.unusedLabel=error +org.eclipse.jdt.core.compiler.problem.unusedLocal=error +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=error +org.eclipse.jdt.core.compiler.problem.unusedParameter=error +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error +org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=error +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=error +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=error +org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 diff -Nru wala-1.3.9/com.ibm.wala.cast/.settings/org.eclipse.pde.prefs wala-1.5.1/com.ibm.wala.cast/.settings/org.eclipse.pde.prefs --- wala-1.3.9/com.ibm.wala.cast/.settings/org.eclipse.pde.prefs 1970-01-01 00:00:00.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/.settings/org.eclipse.pde.prefs 2019-01-29 17:08:39.000000000 +0000 @@ -0,0 +1,32 @@ +compilers.f.unresolved-features=0 +compilers.f.unresolved-plugins=0 +compilers.incompatible-environment=0 +compilers.p.build=2 +compilers.p.build.bin.includes=2 +compilers.p.build.encodings=0 +compilers.p.build.java.compiler=0 +compilers.p.build.java.compliance=0 +compilers.p.build.missing.output=0 +compilers.p.build.output.library=2 +compilers.p.build.source.library=2 +compilers.p.build.src.includes=0 +compilers.p.deprecated=0 +compilers.p.discouraged-class=0 +compilers.p.internal=0 +compilers.p.missing-packages=0 +compilers.p.missing-version-export-package=2 +compilers.p.missing-version-import-package=0 +compilers.p.missing-version-require-bundle=2 +compilers.p.no-required-att=0 +compilers.p.not-externalized-att=0 +compilers.p.unknown-attribute=0 +compilers.p.unknown-class=0 +compilers.p.unknown-element=0 +compilers.p.unknown-identifier=0 +compilers.p.unknown-resource=0 +compilers.p.unresolved-ex-points=0 +compilers.p.unresolved-import=2 +compilers.s.create-docs=false +compilers.s.doc-folder=doc +compilers.s.open-tags=0 +eclipse.preferences.version=1 diff -Nru wala-1.3.9/com.ibm.wala.cast/.settings/org.eclipse.wst.validation.prefs wala-1.5.1/com.ibm.wala.cast/.settings/org.eclipse.wst.validation.prefs --- wala-1.3.9/com.ibm.wala.cast/.settings/org.eclipse.wst.validation.prefs 1970-01-01 00:00:00.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/.settings/org.eclipse.wst.validation.prefs 2019-01-29 17:08:39.000000000 +0000 @@ -0,0 +1,10 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorList +USER_MANUAL_PREFERENCE=enabledManualValidatorList +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.700.v201610061600 +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.wst.html.core.HTMLValidator/groups=0107include06111contentType136org.eclipse.wst.html.core.htmlsourceT07fileext04htmlF07fileext05xhtmlF07fileext03htmF07fileext04htplF07fileext03wmlF0107exclude0104file139target/site/dependency-convergence.htmlT03 +vals/org.eclipse.wst.xml.core.xml/groups=0107include05111contentType128org.eclipse.core.runtime.xmlT111contentType134org.eclipse.wst.xml.core.xmlsourceT111contentType134org.eclipse.wst.xml.core.xslsourceT111contentType134org.eclipse.jst.jsp.core.tldsourceT07fileext03xmlF0107exclude07113projectNature134org.eclipse.jst.j2ee.ejb.EJBNature113projectNature130org.eclipse.jst.j2ee.EARNature04file08.projectT0104file110.classpathT0104file110.settings/T0204file122target/p2artifacts.xmlT0304file120target/p2content.xmlT03 +vf.version=3 diff -Nru wala-1.3.9/com.ibm.wala.cast/source/c/cbuild.sh wala-1.5.1/com.ibm.wala.cast/source/c/cbuild.sh --- wala-1.3.9/com.ibm.wala.cast/source/c/cbuild.sh 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/c/cbuild.sh 2019-01-29 17:08:39.000000000 +0000 @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -eu if (uname | grep -i "cygwin"); then # This should be the default for most of cases; @@ -8,5 +8,9 @@ cmd.exe /c "call \"$MSVC\\vcvarsall.bat\" $ARCH && make" else - make + make --quiet fi + +# Local variables: +# eval: (smie-config-local '((8 :after "else" 2) (8 :elem basic 2))) +# End: diff -Nru wala-1.3.9/com.ibm.wala.cast/source/c/.cvsignore wala-1.5.1/com.ibm.wala.cast/source/c/.cvsignore --- wala-1.3.9/com.ibm.wala.cast/source/c/.cvsignore 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/c/.cvsignore 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -Makefile.configuration -CAstWrapper.lib -CAstWrapper.exp diff -Nru wala-1.3.9/com.ibm.wala.cast/source/c/include/cast_constants.h wala-1.5.1/com.ibm.wala.cast/source/c/include/cast_constants.h --- wala-1.3.9/com.ibm.wala.cast/source/c/include/cast_constants.h 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/c/include/cast_constants.h 2019-01-29 17:08:39.000000000 +0000 @@ -87,6 +87,13 @@ _CAstNodeType(INCLUDE) _CAstNodeType(NAMED_ENTITY_REF); _CAstNodeType(MACRO_VAR); +_CAstNodeType(COMPREHENSION_EXPR); +_CAstNodeType(NEW_ENCLOSING); +_CAstNodeType(NARY_EXPR); +_CAstNodeType(SPECIAL_PARENT_SCOPE); +_CAstNodeType(YIELD_STMT); +_CAstNodeType(FORIN_LOOP); +_CAstNodeType(TYPE_LITERAL_EXPR); #undef _CODE_CONSTANTS #undef _CPP_CONSTANTS diff -Nru wala-1.3.9/com.ibm.wala.cast/source/c/include/CAstWrapper.h wala-1.5.1/com.ibm.wala.cast/source/c/include/CAstWrapper.h --- wala-1.3.9/com.ibm.wala.cast/source/c/include/CAstWrapper.h 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/c/include/CAstWrapper.h 2019-01-29 17:08:39.000000000 +0000 @@ -4,6 +4,7 @@ #include #include "jni.h" #include "Exceptions.h" +#include "launch.h" using namespace std; @@ -53,6 +54,7 @@ jclass CAstInterface; jclass CAstPrinter; jclass CAstSymbol; + jclass CAstType; jclass NativeEntity; jclass NativeClassEntity; jclass NativeCodeEntity; @@ -103,6 +105,9 @@ jmethodID codeSetLabelledGotoTarget; jobject callReference; + static bool initialized; + static void initialize(JNIEnv *java_env); + public: #define _INCLUDE_CONSTANTS @@ -121,6 +126,8 @@ CAstWrapper(JNIEnv *env, Exceptions &ex, jobject Ast); + virtual ~CAstWrapper() { } + void assertIsCAstNode(jobject, int); jobject makeNode(int); diff -Nru wala-1.3.9/com.ibm.wala.cast/source/c/include/Exceptions.h wala-1.5.1/com.ibm.wala.cast/source/c/include/Exceptions.h --- wala-1.3.9/com.ibm.wala.cast/source/c/include/Exceptions.h 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/c/include/Exceptions.h 2019-01-29 17:08:39.000000000 +0000 @@ -37,7 +37,14 @@ #define CATCH() \ } \ -} \ +} + +#define START_CATCH_BLOCK() \ + } else { + +#define END_CATCH_BLOCK() \ + } \ +} #define THROW(CPP_EXP_NAME, MESSAGE) \ (CPP_EXP_NAME).throwException(__FILE__, __LINE__, MESSAGE) @@ -45,6 +52,11 @@ #define THROW_ANY_EXCEPTION(CPP_EXP_NAME) \ (CPP_EXP_NAME).throwAnyException(__FILE__, __LINE__) +#define NULL_CHECK(cpp_exp_name, c_expr) \ + if ((c_expr) == NULL) { \ + (CPP_EXP_NAME).throwException(__FILE__, __LINE__, "unexpected null value"); \ +} + #if __WIN32__ #ifdef BUILD_CAST_DLL #define DLLEXPORT __declspec(dllexport) diff -Nru wala-1.3.9/com.ibm.wala.cast/source/c/include/launch.h wala-1.5.1/com.ibm.wala.cast/source/c/include/launch.h --- wala-1.3.9/com.ibm.wala.cast/source/c/include/launch.h 1970-01-01 00:00:00.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/c/include/launch.h 2019-01-29 17:08:39.000000000 +0000 @@ -0,0 +1,9 @@ +#ifndef _CAST_LAUNCH_H +#define _CAST_LAUNCH_H + +#include "jni.h" + +extern JNIEnv *launch_jvm(char *); +extern void kill(); + +#endif diff -Nru wala-1.3.9/com.ibm.wala.cast/source/c/jni/CAstWrapper.cpp wala-1.5.1/com.ibm.wala.cast/source/c/jni/CAstWrapper.cpp --- wala-1.3.9/com.ibm.wala.cast/source/c/jni/CAstWrapper.cpp 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/c/jni/CAstWrapper.cpp 2019-01-29 17:08:39.000000000 +0000 @@ -1,20 +1,18 @@ -#include - -#include - -#include -#include #include - -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__APPLE__) -#define strndup(s,n) strdup(s) -#endif +#include +#include +#include +#include +#include #define __SIG( __nm ) "L" __nm ";" #define __CTN "com/ibm/wala/cast/tree/CAst" #define __CTS __SIG( __CTN ) +#define __CTI "com/ibm/wala/cast/tree/impl/CAstImpl" +#define __CII __SIG( __CTI ) + #define __CEN "com/ibm/wala/cast/tree/CAstEntity" #define __CES __SIG( __CEN ) @@ -66,6 +64,11 @@ CAstWrapper::CAstWrapper(JNIEnv *env, Exceptions &ex, jobject xlator) : java_ex(ex), env(env), xlator(xlator) { + if (!initialized) { + initialized = true; + initialize(env); + } + this->CAstNode = env->FindClass( __CNN ); this->CAstInterface = env->FindClass( __CTN ); this->HashSet = env->FindClass("java/util/HashSet"); @@ -74,11 +77,15 @@ env->FindClass("com/ibm/wala/cast/ir/translator/NativeBridge"); this->NativeTranslatorToCAst = env->FindClass("com/ibm/wala/cast/ir/translator/NativeTranslatorToCAst"); + THROW_ANY_EXCEPTION(java_ex); jfieldID castFieldID = env->GetFieldID(NativeBridge, "Ast", "Lcom/ibm/wala/cast/tree/CAst;"); + THROW_ANY_EXCEPTION(java_ex); this->Ast = env->GetObjectField(xlator, castFieldID); + THROW_ANY_EXCEPTION(java_ex); jclass xlatorCls = env->FindClass( XlatorCls ); + THROW_ANY_EXCEPTION(java_ex); this->_makeLocation = env->GetMethodID(xlatorCls, "makeLocation", "(IIII)Lcom/ibm/wala/cast/tree/CAstSourcePositionMap$Position;"); THROW_ANY_EXCEPTION(java_ex); @@ -206,21 +213,21 @@ THROW_ANY_EXCEPTION(java_ex); this->_getEntityName = env->GetMethodID(castEntity, "getName", "()Ljava/lang/String;"); + CAstType = env->FindClass("com/ibm/wala/cast/tree/CAstType"); CAstSymbol = env->FindClass("com/ibm/wala/cast/tree/impl/CAstSymbolImpl"); THROW_ANY_EXCEPTION(java_ex); this->castSymbolInit1 = - env->GetMethodID(CAstSymbol, "", "(Ljava/lang/String;)V"); + env->GetMethodID(CAstSymbol, "", "(Ljava/lang/String;Lcom/ibm/wala/cast/tree/CAstType;)V"); THROW_ANY_EXCEPTION(java_ex); this->castSymbolInit2 = - env->GetMethodID(CAstSymbol, "", "(Ljava/lang/String;Z)V"); + env->GetMethodID(CAstSymbol, "", "(Ljava/lang/String;Lcom/ibm/wala/cast/tree/CAstType;Z)V"); THROW_ANY_EXCEPTION(java_ex); this->castSymbolInit3 = - env->GetMethodID(CAstSymbol, "", "(Ljava/lang/String;ZZ)V"); + env->GetMethodID(CAstSymbol, "", "(Ljava/lang/String;Lcom/ibm/wala/cast/tree/CAstType;ZZ)V"); THROW_ANY_EXCEPTION(java_ex); this->castSymbolInit4 = - env->GetMethodID(CAstSymbol, "", "(Ljava/lang/String;ZZLjava/lang/Object;)V"); + env->GetMethodID(CAstSymbol, "", "(Ljava/lang/String;Lcom/ibm/wala/cast/tree/CAstType;ZZLjava/lang/Object;)V"); THROW_ANY_EXCEPTION(java_ex); - } #define _CPP_CONSTANTS @@ -252,16 +259,13 @@ jstring jclsstr = (jstring)env->CallObjectMethod(cls, toString); const char *cclsstr = env->GetStringUTFChars(jclsstr, NULL); -#if defined(_MSC_VER) - char* buf = (char*)_alloca(strlen(cstr) + strlen(cclsstr) + 100); -#else - char buf[ strlen(cstr) + strlen(cclsstr) + 100 ]; -#endif - sprintf(buf, "argument %d (%s of type %s) is not a CAstNode\n", n, cstr, cclsstr); + ostringstream formatter; + formatter << "argument " << n << " (" << cstr << " of type " << cclsstr << ") is not a CAstNode\n"; + const string message = formatter.str(); env->ReleaseStringUTFChars(jstr, cstr); env->ReleaseStringUTFChars(jclsstr, cclsstr); - THROW(java_ex, buf); + THROW(java_ex, message.c_str()); } } @@ -405,14 +409,12 @@ return r; } -jobject CAstWrapper::makeConstant(const char *strData) { - return makeConstant(strData, strlen(strData)); +jobject CAstWrapper::makeConstant(const char *strData, int strLen) { + return makeConstant(string(strData, strLen).c_str()); } -jobject CAstWrapper::makeConstant(const char *strData, int strLen) { - char *safeData = strndup(strData, strLen); - jobject val = env->NewStringUTF( safeData ); - delete safeData; +jobject CAstWrapper::makeConstant(const char *strData) { + jobject val = env->NewStringUTF( strData ); jobject r = env->CallObjectMethod(Ast, makeObject, val); THROW_ANY_EXCEPTION(java_ex); LOG(r); @@ -576,9 +578,7 @@ } jobject CAstWrapper::makeSymbol(const char *name) { - char *safeName = strndup(name, strlen(name)+1); - jobject val = env->NewStringUTF( safeName ); - delete safeName; + jobject val = env->NewStringUTF( name ); jobject s = env->NewObject(CAstSymbol, castSymbolInit1, val); THROW_ANY_EXCEPTION(java_ex); @@ -588,9 +588,7 @@ } jobject CAstWrapper::makeSymbol(const char *name, bool isFinal) { - char *safeName = strndup(name, strlen(name)+1); - jobject val = env->NewStringUTF( safeName ); - delete safeName; + jobject val = env->NewStringUTF( name ); THROW_ANY_EXCEPTION(java_ex); @@ -602,9 +600,7 @@ jobject CAstWrapper::makeSymbol(const char *name, bool isFinal, bool isCaseInsensitive) { - char *safeName = strndup(name, strlen(name)+1); - jobject val = env->NewStringUTF( safeName ); - delete safeName; + jobject val = env->NewStringUTF( name ); jobject s = env->NewObject(CAstSymbol, castSymbolInit3, val, isFinal, isCaseInsensitive); THROW_ANY_EXCEPTION(java_ex); @@ -619,9 +615,7 @@ bool isCaseInsensitive, jobject defaultValue) { - char *safeName = strndup(name, strlen(name)+1); - jobject val = env->NewStringUTF( safeName ); - delete safeName; + jobject val = env->NewStringUTF( name ); jobject s = env->NewObject(CAstSymbol, castSymbolInit4, val, isFinal, isCaseInsensitive, defaultValue); THROW_ANY_EXCEPTION(java_ex); @@ -691,10 +685,8 @@ } jobject CAstWrapper::makeGlobalEntity(char *name, jobject type, list *modifiers) { - char *safeData = strdup(name); - jobject val = env->NewStringUTF( safeData ); + jobject val = env->NewStringUTF( name ); THROW_ANY_EXCEPTION(java_ex); - delete safeData; jobject entity = env->NewObject(NativeGlobalEntity, globalEntityInit, val, type, makeSet(modifiers)); THROW_ANY_EXCEPTION(java_ex); diff -Nru wala-1.3.9/com.ibm.wala.cast/source/c/jni/Exceptions.cpp wala-1.5.1/com.ibm.wala.cast/source/c/jni/Exceptions.cpp --- wala-1.3.9/com.ibm.wala.cast/source/c/jni/Exceptions.cpp 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/c/jni/Exceptions.cpp 2019-01-29 17:08:39.000000000 +0000 @@ -1,11 +1,12 @@ +#include #include -#include -#include +#include +#include #include "Exceptions.h" -#ifdef _MSC_VER -#include -#endif +using std::ostringstream; +using std::string; + Exceptions::Exceptions(JNIEnv *java_env, jmp_buf& c_env) : _java_env(java_env), @@ -23,14 +24,18 @@ if (_java_env->ExceptionCheck()) throwException(file_name, line_number); } +static void formatExceptionMessage(ostringstream &formatter, const char *file_name, int line_number) { + formatter << "exception at " << file_name << ':' << line_number; +} + void Exceptions::throwException(const char *file_name, int line_number) { jthrowable real_ex = _java_env->ExceptionOccurred(); _java_env->ExceptionClear(); - char msg[strlen(file_name) + 1024]; - memset(msg, 0, strlen(file_name) + 1024); - sprintf(msg, "exception at %s:%d", file_name, line_number); - jstring java_message = _java_env->NewStringUTF(msg); + ostringstream formatter; + formatExceptionMessage(formatter, file_name, line_number); + string message = formatter.str(); + jstring java_message = _java_env->NewStringUTF(message.c_str()); jthrowable ex = (jthrowable) _java_env->NewObject(_jre, _wrapper_ctr, java_message, real_ex); @@ -47,10 +52,11 @@ void Exceptions::throwException(const char *file_name, int line_number, const char *c_message) { - char msg[strlen(file_name) + strlen(c_message) + 1024]; - memset(msg, 0, strlen(file_name) + strlen(c_message) + 1024); - sprintf(msg, "exception at %s:%d: %s", file_name, line_number, c_message); - jstring java_message = _java_env->NewStringUTF(msg); + ostringstream formatter; + formatExceptionMessage(formatter, file_name, line_number); + formatter << ": " << c_message; + string message = formatter.str(); + jstring java_message = _java_env->NewStringUTF(message.c_str()); jthrowable ex = (jthrowable)_java_env->NewObject(_jre, _ctr, java_message); _java_env->Throw(ex); diff -Nru wala-1.3.9/com.ibm.wala.cast/source/c/jni/Java_com_ibm_wala_cast_ir_translator_NativeBridge.cpp wala-1.5.1/com.ibm.wala.cast/source/c/jni/Java_com_ibm_wala_cast_ir_translator_NativeBridge.cpp --- wala-1.3.9/com.ibm.wala.cast/source/c/jni/Java_com_ibm_wala_cast_ir_translator_NativeBridge.cpp 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/c/jni/Java_com_ibm_wala_cast_ir_translator_NativeBridge.cpp 2019-01-29 17:08:39.000000000 +0000 @@ -3,15 +3,10 @@ #include "CAstWrapper.h" #include "Exceptions.h" -#include "com_ibm_wala_cast_ir_translator_NativeBridge.h" -extern "C" { +bool CAstWrapper::initialized = false; -JNIEXPORT void JNICALL -Java_com_ibm_wala_cast_ir_translator_NativeBridge_initialize( - JNIEnv *env, - jclass cls) -{ +void CAstWrapper::initialize(JNIEnv *env) { TRY(exp, env) jclass CAstNode = env->FindClass( "com/ibm/wala/cast/tree/CAstNode" ); @@ -38,4 +33,3 @@ CATCH() } -} diff -Nru wala-1.3.9/com.ibm.wala.cast/source/c/jni/launch.cpp wala-1.5.1/com.ibm.wala.cast/source/c/jni/launch.cpp --- wala-1.3.9/com.ibm.wala.cast/source/c/jni/launch.cpp 1970-01-01 00:00:00.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/c/jni/launch.cpp 2019-01-29 17:08:39.000000000 +0000 @@ -0,0 +1,47 @@ +#include + #include +#include +#include "Exceptions.h" +#include "CAstWrapper.h" +#include "launch.h" + +JavaVM *javaVM; + +static string javaPathFlag(const string &kind, const char *classpath) { + return "-Djava." + kind + ".path=" + classpath; +} + +JNIEnv *launch_jvm(char *classpath) { + JavaVMOption jvmopt[2]; + + string buf_jcp = javaPathFlag("class", classpath); + jvmopt[0].optionString = const_cast(buf_jcp.c_str()); + + string buf_jlp = javaPathFlag("library", classpath); + jvmopt[1].optionString = const_cast(buf_jlp.c_str()); + + JavaVMInitArgs vmArgs; + vmArgs.version = JNI_VERSION_1_8; + vmArgs.nOptions = 2; + vmArgs.options = jvmopt; + vmArgs.ignoreUnrecognized = JNI_TRUE; + + // Create the JVM + JNIEnv *jniEnv; + long flag = JNI_CreateJavaVM(&javaVM, (void**) + &jniEnv, &vmArgs); + if (flag == JNI_ERR) { + fprintf(stderr, "Error creating VM. Exiting...\n"); + return NULL; + } + + return jniEnv; +} + +void kill() { + javaVM->DestroyJavaVM(); +} + +// Local variables: +// c-basic-offset: 3 +// End: diff -Nru wala-1.3.9/com.ibm.wala.cast/source/c/Makefile wala-1.5.1/com.ibm.wala.cast/source/c/Makefile --- wala-1.3.9/com.ibm.wala.cast/source/c/Makefile 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/c/Makefile 2019-01-29 17:08:39.000000000 +0000 @@ -1,87 +1,32 @@ include Makefile.configuration -# -# in theory, these definitions should not need to be changed -# - -ifeq (x$(PLATFORM),x) - PLATFORM=$(shell uname -s) -endif - -C_GENERATED=$(DOMO_AST_BIN)libcast/ - -JAVAH_GENERATED=$(C_GENERATED) -ifeq ($(PLATFORM),windows) - CC=i686-mingw32-g++ -else - CC=g++ -endif - -vpath %.cpp jni - -JAVA_INCLUDES = -I$(JAVA_SDK)include - -CAPA_INCLUDE_DIR = include/ -CAPA_INCLUDES = -I$(CAPA_INCLUDE_DIR) -I$(C_GENERATED) - -CAPA_JNI_BRIDGE_HEADER = $(C_GENERATED)com_ibm_wala_cast_ir_translator_NativeBridge.h -CAPA_JNI_XLATOR_HEADER = $(C_GENERATED)com_ibm_wala_cast_ir_translator_NativeTranslatorToCAst.h -CAPA_JNI_HEADERS = $(CAPA_JNI_BRIDGE_HEADER) $(CAPA_JNI_XLATOR_HEADER) - -INCLUDES = $(CAPA_INCLUDES) $(JAVA_INCLUDES) - -CAPA_SOURCES = $(notdir $(wildcard jni/*.cpp)) -CAPA_OBJECTS = $(patsubst %.cpp,$(C_GENERATED)%.o,$(CAPA_SOURCES)) - -ifeq ($(PLATFORM),windows) - ALL_FLAGS = -gstabs+ $(TRACE) $(INCLUDES) -DBUILD_CAST_DLL - DLLEXT = dll -else -ifeq ($(PLATFORM),Darwin) - ALL_FLAGS = -gstabs+ $(TRACE) $(INCLUDES) -fPIC - DLLEXT = jnilib -else - ALL_FLAGS = -pthread -gstabs+ $(TRACE) $(INCLUDES) -fPIC - DLLEXT = so -endif -endif - -ifeq ($(PLATFORM),windows) - CC_LDFLAGS = -shared -Wl,--add-stdcall-alias -Wl,-export-all-symbols - LIBPREFIX = -else -ifeq ($(PLATFORM),Darwin) - CC_LDFLAGS = -dynamiclib -Wl,-flat_namespace - LIBPREFIX = lib -else - CC_LDFLAGS = -pthread -shared - LIBPREFIX = lib -endif -endif +include Makefile.definitions # # rules # -default: $(DOMO_AST_BIN)$(LIBPREFIX)cast.$(DLLEXT) +default: $(DOMO_AST_BIN)$(LIBPREFIX)cast.$(DLLEXT) $(DOMO_AST_BIN)$(LIBPREFIX)cast.a bindir: mkdir -p $(C_GENERATED) $(CAPA_JNI_BRIDGE_HEADER): $(DOMO_AST_BIN)com/ibm/wala/cast/ir/translator/NativeBridge.class bindir - $(JAVA_SDK)bin/javah -classpath "$(DOMO_AST_BIN)$(JAVAH_CLASS_PATH)" -d "$(JAVAH_GENERATED)" com.ibm.wala.cast.ir.translator.NativeBridge + $(JAVA_HOME)/bin/javah -classpath "$(DOMO_AST_BIN)$(JAVAH_CLASS_PATH)" -d "$(JAVAH_GENERATED)" com.ibm.wala.cast.ir.translator.NativeBridge $(CAPA_JNI_XLATOR_HEADER): $(DOMO_AST_BIN)com/ibm/wala/cast/ir/translator/NativeTranslatorToCAst.class bindir - $(JAVA_SDK)bin/javah -classpath "$(DOMO_AST_BIN)$(JAVAH_CLASS_PATH)" -d "$(JAVAH_GENERATED)" com.ibm.wala.cast.ir.translator.NativeTranslatorToCAst + $(JAVA_HOME)/bin/javah -classpath "$(DOMO_AST_BIN)$(JAVAH_CLASS_PATH)" -d "$(JAVAH_GENERATED)" com.ibm.wala.cast.ir.translator.NativeTranslatorToCAst $(CAPA_OBJECTS): $(C_GENERATED)%.o: %.cpp $(CAPA_JNI_HEADERS) bindir - echo $(CAPA_OBJECTS) $(CC) $(ALL_FLAGS) -o $@ -c $< $(DOMO_AST_BIN)$(LIBPREFIX)cast.$(DLLEXT): $(CAPA_OBJECTS) $(CC) $(CC_LDFLAGS) $^ -o $@ +$(DOMO_AST_BIN)$(LIBPREFIX)cast.a: $(CAPA_OBJECTS) + ar -r $@ $^ + clean: rm -rf $(C_GENERATED) hs_err_pid* diff -Nru wala-1.3.9/com.ibm.wala.cast/source/c/Makefile.configuration wala-1.5.1/com.ibm.wala.cast/source/c/Makefile.configuration --- wala-1.3.9/com.ibm.wala.cast/source/c/Makefile.configuration 1970-01-01 00:00:00.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/c/Makefile.configuration 2019-01-29 17:08:39.000000000 +0000 @@ -0,0 +1,12 @@ +# -*- makefile -*- + +# configuration of installed Java SDK +JRE_DIR := $(shell java -XshowSettings:properties -version 2>&1 | sed -n 's/^ *java\.home = \(.*\)/\1/p')/ +JAVA_SDK := $(realpath $(JRE_DIR)..)/ +JNI_MD_DIR := $(notdir $(patsubst %/,%,$(dir $(wildcard $(JAVA_SDK)include/*/jni_md.h)))) + +# configuration of WALA build tree +CAST_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))../..)/ +DOMO_AST_BIN := $(CAST_DIR)target/classes/ +JAVAH_CLASS_PATH := :$(CAST_DIR)target/classes/ +TRACE := diff -Nru wala-1.3.9/com.ibm.wala.cast/source/c/Makefile.configuration.sample wala-1.5.1/com.ibm.wala.cast/source/c/Makefile.configuration.sample --- wala-1.3.9/com.ibm.wala.cast/source/c/Makefile.configuration.sample 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/c/Makefile.configuration.sample 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -# -# global configuration. adjust for your system. -# - -# The root of the java SDK to use (must end in /) -JAVA_SDK = /System/Library/Frameworks/JavaVM.framework/Home/ - -# Path .class files of the com.ibm.domo.ast Java code (must end in /) -DOMO_AST_BIN = /com.ibm.wala.cast/bin/ - -# Extra stuff needed in the classpath of javah (must start with path separator) -JAVAH_CLASS_PATH = :/com.ibm.wala.cast/bin/ - -# enable debugging flags -TRACE = diff -Nru wala-1.3.9/com.ibm.wala.cast/source/c/Makefile.definitions wala-1.5.1/com.ibm.wala.cast/source/c/Makefile.definitions --- wala-1.3.9/com.ibm.wala.cast/source/c/Makefile.definitions 1970-01-01 00:00:00.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/c/Makefile.definitions 2019-01-29 17:08:39.000000000 +0000 @@ -0,0 +1,64 @@ +# +# in theory, these definitions should not need to be changed +# + +ifeq (x$(PLATFORM),x) + PLATFORM=$(shell uname -s) +endif + +C_GENERATED=$(DOMO_AST_BIN)libcast/ + +JAVAH_GENERATED=$(C_GENERATED) +ifeq ($(PLATFORM),windows) + CC=i686-mingw32-g++ +else + CC=g++ +endif + +vpath %.cpp jni + +JAVA_INCLUDES = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/$(JNI_MD_DIR) -DWALA_CLASSPATH="\"$(DOMO_AST_BIN)$(JAVAH_CLASS_PATH)\"" + +CAPA_INCLUDE_DIR = ../../../com.ibm.wala.cast/source/c/include/ +CAPA_INCLUDES = -I$(CAPA_INCLUDE_DIR) -I$(C_GENERATED) + +CAPA_JNI_BRIDGE_HEADER = $(C_GENERATED)com_ibm_wala_cast_ir_translator_NativeBridge.h +CAPA_JNI_XLATOR_HEADER = $(C_GENERATED)com_ibm_wala_cast_ir_translator_NativeTranslatorToCAst.h +CAPA_JNI_HEADERS = $(CAPA_JNI_BRIDGE_HEADER) $(CAPA_JNI_XLATOR_HEADER) + +INCLUDES = $(CAPA_INCLUDES) $(JAVA_INCLUDES) + +CAPA_SOURCES = $(notdir $(wildcard jni/*.cpp)) +CAPA_OBJECTS = $(patsubst %.cpp,$(C_GENERATED)%.o,$(CAPA_SOURCES)) + +ifeq ($(PLATFORM),windows) + ALL_FLAGS = -g $(TRACE) $(INCLUDES) -DBUILD_CAST_DLL + DLLEXT = dll +else +ifeq ($(PLATFORM),Darwin) + ALL_FLAGS = -g $(TRACE) $(INCLUDES) -fPIC + DLLEXT = jnilib +else + ALL_FLAGS = -pthread -g $(TRACE) $(INCLUDES) -fPIC + DLLEXT = so +endif +endif + +ifeq ($(PLATFORM),windows) + CC_LDFLAGS = -shared -Wl,--add-stdcall-alias -Wl,-export-all-symbols + LIBPREFIX = +else +ifeq ($(PLATFORM),Darwin) + CC_LDFLAGS = -dynamiclib -Wl,-flat_namespace + LIBPREFIX = lib +else + CC_LDFLAGS = -pthread -shared + LIBPREFIX = lib +endif +endif + +CC_LD_PATHS = -L$(JAVA_HOME)/jre/lib/amd64/server -Wl,-rpath -Wl,$(JAVA_HOME)/jre/lib/amd64/server -L$(JAVA_HOME)/jre/lib/x86_64/server -Wl,-rpath -Wl,$(JAVA_HOME)/jre/lib/x86_64/server -L$(JAVA_HOME)/jre/lib/x64/server -Wl,-rpath -Wl,$(JAVA_HOME)/jre/lib/x64/server -L$(JAVA_HOME)/jre/lib/server -Wl,-rpath -Wl,$(JAVA_HOME)/jre/lib/server -L$(JAVA_HOME)/jre/lib -Wl,-rpath -Wl,$(JAVA_HOME)/jre/lib -ljvm + +CC_LDFLAGS += $(CC_LD_PATHS) + + diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/analysis/typeInference/AstTypeInference.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/analysis/typeInference/AstTypeInference.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/analysis/typeInference/AstTypeInference.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/analysis/typeInference/AstTypeInference.java 2019-01-29 17:08:39.000000000 +0000 @@ -21,9 +21,10 @@ import com.ibm.wala.cast.ir.ssa.AstIsDefinedInstruction; import com.ibm.wala.cast.ir.ssa.AstLexicalRead; import com.ibm.wala.cast.ir.ssa.AstLexicalWrite; +import com.ibm.wala.cast.ir.ssa.AstPropertyRead; +import com.ibm.wala.cast.ir.ssa.AstPropertyWrite; import com.ibm.wala.cast.ir.ssa.EachElementGetInstruction; import com.ibm.wala.cast.ir.ssa.EachElementHasNextInstruction; -import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.ssa.IR; public abstract class AstTypeInference extends TypeInference { @@ -32,6 +33,15 @@ protected class AstTypeOperatorFactory extends TypeOperatorFactory implements AstInstructionVisitor { @Override + public void visitPropertyRead(AstPropertyRead inst) { + result = new DeclaredTypeOperator(new ConeType(cha.getRootClass())); + } + + @Override + public void visitPropertyWrite(AstPropertyWrite inst) { + } + + @Override public void visitAstLexicalRead(AstLexicalRead inst) { result = new DeclaredTypeOperator(new ConeType(cha.getRootClass())); } @@ -73,9 +83,9 @@ public void visitEcho(AstEchoInstruction inst) { } - }; + } - public AstTypeInference(IR ir, IClassHierarchy cha, TypeAbstraction booleanType, boolean doPrimitives) { + public AstTypeInference(IR ir, TypeAbstraction booleanType, boolean doPrimitives) { super(ir, doPrimitives); this.booleanType = booleanType; } diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/ArgumentInstanceContext.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/ArgumentInstanceContext.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/ArgumentInstanceContext.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/ArgumentInstanceContext.java 2019-01-29 17:08:39.000000000 +0000 @@ -75,8 +75,8 @@ @Override public String toString() { - return "ArgumentInstanceContext [base=" + base + ", index=" + index + ", instanceKey=" + instanceKey + "]"; + return "ArgumentInstanceContext [base=" + base + ", index=" + index + ", instanceKey=" + instanceKey + ']'; } -} \ No newline at end of file +} diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstCallGraph.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstCallGraph.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstCallGraph.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstCallGraph.java 2019-01-29 17:08:39.000000000 +0000 @@ -11,8 +11,8 @@ package com.ibm.wala.cast.ipa.callgraph; import java.util.ConcurrentModificationException; -import java.util.Iterator; import java.util.Set; +import java.util.function.Function; import com.ibm.wala.cast.ir.cfg.AstInducedCFG; import com.ibm.wala.cast.ir.ssa.AstLexicalRead; @@ -20,37 +20,35 @@ import com.ibm.wala.classLoader.CallSiteReference; import com.ibm.wala.classLoader.IClass; import com.ibm.wala.classLoader.IMethod; -import com.ibm.wala.ipa.callgraph.AnalysisCache; +import com.ibm.wala.classLoader.NewSiteReference; import com.ibm.wala.ipa.callgraph.AnalysisOptions; import com.ibm.wala.ipa.callgraph.CGNode; import com.ibm.wala.ipa.callgraph.Context; +import com.ibm.wala.ipa.callgraph.IAnalysisCacheView; import com.ibm.wala.ipa.callgraph.impl.AbstractRootMethod; import com.ibm.wala.ipa.callgraph.impl.Everywhere; import com.ibm.wala.ipa.callgraph.impl.ExplicitCallGraph; -import com.ibm.wala.ipa.callgraph.impl.FakeRootMethod; import com.ibm.wala.ipa.cha.IClassHierarchy; -import com.ibm.wala.ssa.DefUse; -import com.ibm.wala.ssa.IR; import com.ibm.wala.ssa.SSAAbstractInvokeInstruction; import com.ibm.wala.ssa.SSAInstruction; +import com.ibm.wala.ssa.SSANewInstruction; import com.ibm.wala.types.MethodReference; import com.ibm.wala.types.TypeReference; -import com.ibm.wala.util.CancelException; import com.ibm.wala.util.collections.HashSetFactory; -import com.ibm.wala.util.functions.Function; +import com.ibm.wala.util.collections.Iterator2Iterable; public class AstCallGraph extends ExplicitCallGraph { - public AstCallGraph(IClassHierarchy cha, AnalysisOptions options, AnalysisCache cache) { - super(cha, options, cache); + public AstCallGraph(IMethod fakeRootClass2, AnalysisOptions options, IAnalysisCacheView cache) { + super(fakeRootClass2, options, cache); } public static class AstFakeRoot extends AbstractRootMethod { - public AstFakeRoot(MethodReference rootMethod, IClass declaringClass, IClassHierarchy cha, AnalysisOptions options, AnalysisCache cache) { + public AstFakeRoot(MethodReference rootMethod, IClass declaringClass, IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) { super(rootMethod, declaringClass, cha, options, cache); } - public AstFakeRoot(MethodReference rootMethod, IClassHierarchy cha, AnalysisOptions options, AnalysisCache cache) { + public AstFakeRoot(MethodReference rootMethod, IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) { super(rootMethod, cha, options, cache); } @@ -68,25 +66,34 @@ public static abstract class ScriptFakeRoot extends AstFakeRoot { - public ScriptFakeRoot(MethodReference rootMethod, IClass declaringClass, IClassHierarchy cha, AnalysisOptions options, AnalysisCache cache) { + public ScriptFakeRoot(MethodReference rootMethod, IClass declaringClass, IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) { super(rootMethod, declaringClass, cha, options, cache); } - public ScriptFakeRoot(MethodReference rootMethod, IClassHierarchy cha, AnalysisOptions options, AnalysisCache cache) { + public ScriptFakeRoot(MethodReference rootMethod, IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) { super(rootMethod, cha, options, cache); } public abstract SSAAbstractInvokeInstruction addDirectCall(int functionVn, int[] argVns, CallSiteReference callSite); + @Override + public SSANewInstruction addAllocation(TypeReference T) { + if (cha.isSubclassOf(cha.lookupClass(T), cha.lookupClass(declaringClass.getClassLoader().getLanguage().getRootType()))) { + int instance = nextLocal++; + NewSiteReference ref = NewSiteReference.make(statements.size(), T); + SSANewInstruction result = getDeclaringClass().getClassLoader().getInstructionFactory().NewInstruction(statements.size(), instance, ref); + statements.add(result); + return result; + } else { + return super.addAllocation(T); + } + } + } public class AstCGNode extends ExplicitNode { private Set> callbacks; - private IR cachedIR; - - private DefUse cachedDU; - private AstCGNode(IMethod method, Context context) { super(method, context); } @@ -96,8 +103,8 @@ boolean done = false; while (!done) { try { - for (Iterator> x = callbacks.iterator(); x.hasNext();) { - x.next().apply(null); + for (Function function : callbacks) { + function.apply(null); } } catch (ConcurrentModificationException e) { done = false; @@ -113,7 +120,7 @@ } private boolean hasAllCallbacks(Set> callbacks) { - return callbacks != null && callbacks.containsAll(callbacks); + return callbacks != null && this.callbacks.containsAll(callbacks); } public void addCallback(Function callback) { @@ -124,8 +131,8 @@ callbacks.add(callback); - for (Iterator ps = getCallGraph().getPredNodes(this); ps.hasNext();) { - ((AstCGNode) ps.next()).addCallback(callback); + for (CGNode p : Iterator2Iterable.make(getCallGraph().getPredNodes(this))) { + ((AstCGNode) p).addCallback(callback); } } } @@ -138,8 +145,8 @@ callbacks.addAll(callback); - for (Iterator ps = getCallGraph().getPredNodes(this); ps.hasNext();) { - ((AstCGNode) ps.next()).addAllCallbacks(callback); + for (CGNode p : Iterator2Iterable.make(getCallGraph().getPredNodes(this))) { + ((AstCGNode) p).addAllCallbacks(callback); } } } @@ -167,9 +174,4 @@ return new AstCGNode(method, context); } - @Override - protected CGNode makeFakeRootNode() throws CancelException { - return findOrCreateNode(new AstFakeRoot(FakeRootMethod.rootMethod, cha, options, getAnalysisCache()), Everywhere.EVERYWHERE); - } - } diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstContextInsensitiveSSAContextInterpreter.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstContextInsensitiveSSAContextInterpreter.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstContextInsensitiveSSAContextInterpreter.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstContextInsensitiveSSAContextInterpreter.java 2019-01-29 17:08:39.000000000 +0000 @@ -17,10 +17,9 @@ import com.ibm.wala.classLoader.CodeScanner; import com.ibm.wala.classLoader.IMethod; import com.ibm.wala.classLoader.NewSiteReference; -import com.ibm.wala.ipa.callgraph.AnalysisCache; import com.ibm.wala.ipa.callgraph.AnalysisOptions; import com.ibm.wala.ipa.callgraph.CGNode; -import com.ibm.wala.ipa.callgraph.Context; +import com.ibm.wala.ipa.callgraph.IAnalysisCacheView; import com.ibm.wala.ipa.callgraph.propagation.cfa.ContextInsensitiveSSAInterpreter; import com.ibm.wala.ssa.IR; import com.ibm.wala.util.collections.EmptyIterator; @@ -33,11 +32,11 @@ */ public class AstContextInsensitiveSSAContextInterpreter extends ContextInsensitiveSSAInterpreter { - public AstContextInsensitiveSSAContextInterpreter(AnalysisOptions options, AnalysisCache cache) { + public AstContextInsensitiveSSAContextInterpreter(AnalysisOptions options, IAnalysisCacheView cache) { super(options, cache); } - public boolean understands(IMethod method, Context context) { + public boolean understands(IMethod method) { return method instanceof AstMethod; } diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstGlobalPointerKey.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstGlobalPointerKey.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstGlobalPointerKey.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstGlobalPointerKey.java 2019-01-29 17:08:39.000000000 +0000 @@ -35,7 +35,7 @@ @Override public String toString() { - return "[global: " + globalName + "]"; + return "[global: " + globalName + ']'; } } diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstSSAPropagationCallGraphBuilder.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstSSAPropagationCallGraphBuilder.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstSSAPropagationCallGraphBuilder.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstSSAPropagationCallGraphBuilder.java 2019-01-29 17:08:39.000000000 +0000 @@ -22,26 +22,29 @@ import com.ibm.wala.cast.ir.ssa.AstEchoInstruction; import com.ibm.wala.cast.ir.ssa.AstGlobalRead; import com.ibm.wala.cast.ir.ssa.AstGlobalWrite; -import com.ibm.wala.cast.ir.ssa.AstIRFactory.AstIR; +import com.ibm.wala.cast.ir.ssa.AstIRFactory; import com.ibm.wala.cast.ir.ssa.AstInstructionVisitor; import com.ibm.wala.cast.ir.ssa.AstIsDefinedInstruction; -import com.ibm.wala.cast.ir.ssa.AstLexicalAccess; import com.ibm.wala.cast.ir.ssa.AstLexicalAccess.Access; import com.ibm.wala.cast.ir.ssa.AstLexicalRead; import com.ibm.wala.cast.ir.ssa.AstLexicalWrite; +import com.ibm.wala.cast.ir.ssa.AstPropertyRead; +import com.ibm.wala.cast.ir.ssa.AstPropertyWrite; import com.ibm.wala.cast.ir.ssa.EachElementGetInstruction; import com.ibm.wala.cast.ir.ssa.EachElementHasNextInstruction; import com.ibm.wala.cast.ir.translator.AstTranslator; import com.ibm.wala.cast.loader.AstMethod; import com.ibm.wala.cast.loader.AstMethod.LexicalInformation; +import com.ibm.wala.cast.tree.CAstSourcePositionMap.Position; import com.ibm.wala.classLoader.IClass; +import com.ibm.wala.classLoader.IMethod; import com.ibm.wala.fixpoint.AbstractOperator; import com.ibm.wala.fixpoint.IntSetVariable; import com.ibm.wala.fixpoint.UnaryOperator; -import com.ibm.wala.ipa.callgraph.AnalysisCache; import com.ibm.wala.ipa.callgraph.AnalysisOptions; import com.ibm.wala.ipa.callgraph.CGNode; import com.ibm.wala.ipa.callgraph.CallGraph; +import com.ibm.wala.ipa.callgraph.IAnalysisCacheView; import com.ibm.wala.ipa.callgraph.impl.ExplicitCallGraph; import com.ibm.wala.ipa.callgraph.propagation.AbstractFieldPointerKey; import com.ibm.wala.ipa.callgraph.propagation.HeapModel; @@ -63,14 +66,15 @@ import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.ipa.modref.ArrayLengthKey; import com.ibm.wala.ssa.DefUse; -import com.ibm.wala.ssa.IR; +import com.ibm.wala.ssa.IRView; +import com.ibm.wala.ssa.SSAInstruction; import com.ibm.wala.ssa.SSAPutInstruction; import com.ibm.wala.ssa.SymbolTable; import com.ibm.wala.util.collections.HashSetFactory; +import com.ibm.wala.util.collections.Iterator2Iterable; import com.ibm.wala.util.collections.Pair; import com.ibm.wala.util.debug.Assertions; import com.ibm.wala.util.intset.IntSet; -import com.ibm.wala.util.intset.IntSetAction; import com.ibm.wala.util.intset.IntSetUtil; import com.ibm.wala.util.intset.MutableIntSet; import com.ibm.wala.util.intset.MutableMapping; @@ -102,6 +106,7 @@ * each language can specify whether a particular field name should be stored * in object catalogs or not. By default, always return false. */ + @SuppressWarnings("unused") protected boolean isUncataloguedField(IClass type, String fieldName) { return false; } @@ -115,9 +120,9 @@ public abstract GlobalObjectKey getGlobalObject(Atom language); - protected AstSSAPropagationCallGraphBuilder(IClassHierarchy cha, AnalysisOptions options, AnalysisCache cache, + protected AstSSAPropagationCallGraphBuilder(IMethod fakeRootClass, AnalysisOptions options, IAnalysisCacheView cache, PointerKeyFactory pointerKeyFactory) { - super(cha, options, cache, pointerKeyFactory); + super(fakeRootClass, options, cache, pointerKeyFactory); } public SSAContextInterpreter makeDefaultContextInterpreters(SSAContextInterpreter appContextInterpreter, AnalysisOptions options, @@ -196,6 +201,16 @@ } @Override + public void visitPropertyRead(AstPropertyRead instruction) { + + } + + @Override + public void visitPropertyWrite(AstPropertyWrite instruction) { + + } + + @Override public void visitAstLexicalRead(AstLexicalRead instruction) { } @@ -240,7 +255,7 @@ } } - }; + } // ///////////////////////////////////////////////////////////////////////// // @@ -249,8 +264,8 @@ // ///////////////////////////////////////////////////////////////////////// @Override - protected ExplicitCallGraph createEmptyCallGraph(IClassHierarchy cha, AnalysisOptions options) { - return new AstCallGraph(cha, options, getAnalysisCache()); + protected ExplicitCallGraph createEmptyCallGraph(IMethod fakeRootClass, AnalysisOptions options) { + return new AstCallGraph(fakeRootClass, options, getAnalysisCache()); } public static class AstInterestingVisitor extends InterestingVisitor implements AstInstructionVisitor { @@ -260,6 +275,16 @@ } @Override + public void visitPropertyRead(AstPropertyRead instruction) { + bingo = true; + } + + @Override + public void visitPropertyWrite(AstPropertyWrite instruction) { + bingo = true; + } + + @Override public void visitAstLexicalRead(AstLexicalRead instruction) { bingo = true; } @@ -314,7 +339,7 @@ public boolean hasNoInterestingUses(CGNode node, int vn, DefUse du) { if (node.getMethod() instanceof AstMethod) { // uses in nested functions are interesting - IntSet uses = ((AstIR) node.getIR()).lexicalInfo().getAllExposedUses(); + IntSet uses = ((AstIRFactory.AstIR) node.getIR()).lexicalInfo().getAllExposedUses(); if (uses.contains(vn)) { return false; } @@ -357,8 +382,8 @@ return ((AstPointerKeyFactory) getBuilder().getPointerKeyFactory()).getPointerKeysForReflectedFieldWrite(I, F); } - private void visitLexical(AstLexicalAccess instruction, final LexicalOperator op) { - op.doLexicalPointerKeys(false); + private static void visitLexical(final LexicalOperator op) { + op.doLexicalPointerKeys(); // I have no idea what the code below does, but commenting it out doesn't // break any regression tests. --MS // if (! checkLexicalInstruction(instruction)) { @@ -366,26 +391,56 @@ // } } + @Override + public void visitPropertyRead(AstPropertyRead instruction) { + if (AstSSAPropagationCallGraphBuilder.DEBUG_PROPERTIES) { + Position instructionPosition = getInstructionPosition(instruction); + if (instructionPosition != null) { + System.err.println("processing read instruction " + instruction + ", position " + instructionPosition); + } + } + newFieldRead(node, instruction.getUse(0), instruction.getUse(1), instruction.getDef(0)); + } + + private Position getInstructionPosition(SSAInstruction instruction) { + IMethod method = node.getMethod(); + if (method instanceof AstMethod) { + return ((AstMethod) method).getSourcePosition(instruction.iindex); + } + return null; + } + + @Override + public void visitPropertyWrite(AstPropertyWrite instruction) { + if (AstSSAPropagationCallGraphBuilder.DEBUG_PROPERTIES) { + Position instructionPosition = getInstructionPosition(instruction); + if (instructionPosition != null) { + System.err.println("processing write instruction " + instruction + ", position " + instructionPosition); + } + } + newFieldWrite(node, instruction.getUse(0), instruction.getUse(1), instruction.getUse(2)); + } @Override public void visitAstLexicalRead(AstLexicalRead instruction) { - visitLexical(instruction, new LexicalOperator((AstCGNode) node, instruction.getAccesses(), true) { + visitLexical(new LexicalOperator((AstCGNode) node, instruction.getAccesses(), true) { @Override protected void action(PointerKey lexicalKey, int vn) { PointerKey lval = getPointerKeyForLocal(vn); if (lexicalKey instanceof LocalPointerKey) { CGNode lnode = ((LocalPointerKey) lexicalKey).getNode(); int lvn = ((LocalPointerKey) lexicalKey).getValueNumber(); - IR lir = getBuilder().getCFAContextInterpreter().getIR(lnode); + IRView lir = getBuilder().getCFAContextInterpreter().getIRView(lnode); SymbolTable lsymtab = lir.getSymbolTable(); - DefUse ldu = getAnalysisCache().getSSACache().findOrCreateDU(lir, lnode.getContext()); + DefUse ldu = getBuilder().getCFAContextInterpreter().getDU(lnode); + // DefUse ldu = getAnalysisCache().getDefUse(lir); if (contentsAreInvariant(lsymtab, ldu, lvn)) { InstanceKey[] ik = getInvariantContents(lsymtab, ldu, lnode, lvn); system.recordImplicitPointsToSet(lexicalKey); - for (int i = 0; i < ik.length; i++) { - system.findOrCreateIndexForInstanceKey(ik[i]); - system.newConstraint(lval, ik[i]); + for (InstanceKey element : ik) { + system.findOrCreateIndexForInstanceKey(element); + system.newConstraint(lval, element); } return; @@ -399,16 +454,16 @@ @Override public void visitAstLexicalWrite(AstLexicalWrite instruction) { - visitLexical(instruction, new LexicalOperator((AstCGNode) node, instruction.getAccesses(), false) { + visitLexical(new LexicalOperator((AstCGNode) node, instruction.getAccesses(), false) { @Override protected void action(PointerKey lexicalKey, int vn) { PointerKey rval = getPointerKeyForLocal(vn); if (contentsAreInvariant(symbolTable, du, vn)) { InstanceKey[] ik = getInvariantContents(vn); system.recordImplicitPointsToSet(rval); - for (int i = 0; i < ik.length; i++) { - system.findOrCreateIndexForInstanceKey(ik[i]); - system.newConstraint(lexicalKey, ik[i]); + for (InstanceKey element : ik) { + system.findOrCreateIndexForInstanceKey(element); + system.newConstraint(lexicalKey, element); } } else { system.newConstraint(lexicalKey, assignOperator, rval); @@ -470,17 +525,14 @@ system.newSideEffect(new UnaryOperator() { @Override public byte evaluate(PointsToSetVariable lhs, PointsToSetVariable rhs) { - final IntSetVariable objects = rhs; + final IntSetVariable objects = rhs; if (objects.getValue() != null) { - objects.getValue().foreach(new IntSetAction() { - @Override - public void act(int optr) { - InstanceKey object = system.getInstanceKey(optr); - if (!getBuilder().isUncataloguedField(object.getConcreteType(), hack)) { - PointerKey cat = getPointerKeyForObjectCatalog(object); - if (cat != null) { - system.newConstraint(cat, fieldNameKeys[0]); - } + objects.getValue().foreach(optr -> { + InstanceKey object = system.getInstanceKey(optr); + if (!getBuilder().isUncataloguedField(object.getConcreteType(), hack)) { + PointerKey cat = getPointerKeyForObjectCatalog(object); + if (cat != null) { + system.newConstraint(cat, fieldNameKeys[0]); } } }); @@ -526,8 +578,8 @@ if (contentsAreInvariant(symbolTable, du, rval)) { InstanceKey objects[] = getInvariantContents(rval); - for (int i = 0; i < objects.length; i++) { - PointerKey catalog = getPointerKeyForObjectCatalog(objects[i]); + for (InstanceKey object : objects) { + PointerKey catalog = getPointerKeyForObjectCatalog(object); system.newConstraint(lk, assignOperator, catalog); } } @@ -536,16 +588,13 @@ system.newSideEffect(new UnaryOperator() { @Override public byte evaluate(PointsToSetVariable lhs, PointsToSetVariable rhs) { - final IntSetVariable objects = rhs; + final IntSetVariable objects = rhs; if (objects.getValue() != null) { - objects.getValue().foreach(new IntSetAction() { - @Override - public void act(int optr) { - InstanceKey object = system.getInstanceKey(optr); - PointerKey objCatalog = getPointerKeyForObjectCatalog(object); - if (objCatalog != null) { - system.newConstraint(lk, assignOperator, objCatalog); - } + objects.getValue().foreach(optr -> { + InstanceKey object = system.getInstanceKey(optr); + PointerKey objCatalog = getPointerKeyForObjectCatalog(object); + if (objCatalog != null) { + system.newConstraint(lk, assignOperator, objCatalog); } }); } @@ -612,16 +661,16 @@ * perform the necessary {@link #action(PointerKey, int)}s for the * accesses. For each access, we determine the possible {@link CGNode}s * corresponding to its definer (see - * {@link AstConstraintVisitor#getLexicalDefiners(CGNode, String)). Handle + * {@link AstConstraintVisitor#getLexicalDefiners(CGNode, Pair)}). Handle * using * {@link AstConstraintVisitor#handleRootLexicalReference(String, String, CGNode)} * . */ - private void doLexicalPointerKeys(boolean funargsOnly) { - for (int i = 0; i < accesses.length; i++) { - final String name = accesses[i].variableName; - final String definer = accesses[i].variableDefiner; - final int vn = accesses[i].valueNumber; + private void doLexicalPointerKeys() { + for (Access accesse : accesses) { + final String name = accesse.variableName; + final String definer = accesse.variableDefiner; + final int vn = accesse.valueNumber; if (AstTranslator.DEBUG_LEXICAL) System.err.println(("looking up lexical parent " + definer)); @@ -639,7 +688,7 @@ @Override public byte evaluate(PointsToSetVariable lhs, PointsToSetVariable rhs) { - doLexicalPointerKeys(true); + doLexicalPointerKeys(); return NOT_CHANGED; } @@ -700,15 +749,15 @@ final Set result = HashSetFactory.make(); PointerKey F = getBuilder().getPointerKeyForLocal(opNode, 1); - IR ir = getBuilder().getCFAContextInterpreter().getIR(opNode); + IRView ir = getBuilder().getCFAContextInterpreter().getIRView(opNode); SymbolTable symtab = ir.getSymbolTable(); DefUse du = getBuilder().getCFAContextInterpreter().getDU(opNode); if (contentsAreInvariant(symtab, du, 1)) { system.recordImplicitPointsToSet(F); final InstanceKey[] functionKeys = getInvariantContents(symtab, du, opNode, 1); - for (int f = 0; f < functionKeys.length; f++) { - system.findOrCreateIndexForInstanceKey(functionKeys[f]); - ScopeMappingInstanceKey K = (ScopeMappingInstanceKey) functionKeys[f]; + for (InstanceKey functionKey : functionKeys) { + system.findOrCreateIndexForInstanceKey(functionKey); + ScopeMappingInstanceKey K = (ScopeMappingInstanceKey) functionKey; Iterator x = K.getFunargNodes(definer); while (x.hasNext()) { result.add(x.next()); @@ -717,19 +766,16 @@ } else { PointsToSetVariable FV = system.findOrCreatePointsToSet(F); if (FV.getValue() != null) { - FV.getValue().foreach(new IntSetAction() { - @Override - public void act(int ptr) { - InstanceKey iKey = system.getInstanceKey(ptr); - if (iKey instanceof ScopeMappingInstanceKey) { - ScopeMappingInstanceKey K = (ScopeMappingInstanceKey) iKey; - Iterator x = K.getFunargNodes(definer); - while (x.hasNext()) { - result.add(x.next()); - } - } else { - Assertions.UNREACHABLE("unexpected instance key " + iKey); + FV.getValue().foreach(ptr -> { + InstanceKey iKey = system.getInstanceKey(ptr); + if (iKey instanceof ScopeMappingInstanceKey) { + ScopeMappingInstanceKey K = (ScopeMappingInstanceKey) iKey; + Iterator x = K.getFunargNodes(definer); + while (x.hasNext()) { + result.add(x.next()); } + } else { + //Assertions.UNREACHABLE("unexpected instance key " + iKey); } }); } @@ -739,13 +785,6 @@ } } - private boolean isEqual(Object a, Object b) { - if (a == null) - return b == null; - else - return a.equals(b); - } - private Set discoveredUpwardFunargs = HashSetFactory.make(); /** @@ -755,13 +794,13 @@ private void addUpwardFunargConstraints(PointerKey lhs, String name, String definer, CGNode definingNode) { discoveredUpwardFunargs.add(lhs); - LexicalInformation LI = ((AstIR) definingNode.getIR()).lexicalInfo(); - Pair[] names = LI.getExposedNames(); + LexicalInformation LI = ((AstIRFactory.AstIR) definingNode.getIR()).lexicalInfo(); + Pair[] names = LI.getExposedNames(); for (int i = 0; i < names.length; i++) { if (name.equals(names[i].fst) && definer.equals(names[i].snd)) { int vn = LI.getExitExposedUses()[i]; if (vn > 0) { - IR ir = getBuilder().getCFAContextInterpreter().getIR(definingNode); + IRView ir = getBuilder().getCFAContextInterpreter().getIRView(definingNode); DefUse du = getBuilder().getCFAContextInterpreter().getDU(definingNode); SymbolTable st = ir.getSymbolTable(); @@ -770,9 +809,9 @@ if (contentsAreInvariant(st, du, vn)) { system.recordImplicitPointsToSet(rhs); final InstanceKey[] objs = getInvariantContents(st, du, definingNode, vn); - for (int f = 0; f < objs.length; f++) { - system.findOrCreateIndexForInstanceKey(objs[f]); - system.newConstraint(lhs, objs[f]); + for (InstanceKey obj : objs) { + system.findOrCreateIndexForInstanceKey(obj); + system.newConstraint(lhs, obj); } } else { system.newConstraint(lhs, assignOperator, rhs); @@ -821,7 +860,7 @@ @Override public String toString() { - return "[upward:" + getName() + ":" + definingNode + "]"; + return "[upward:" + getName() + ':' + definingNode + ']'; } } @@ -851,7 +890,7 @@ private void newFieldOperation(CGNode opNode, final int objVn, final int fieldsVn, final boolean isLoadOperation, final ReflectedFieldAction action) { - IR ir = getBuilder().getCFAContextInterpreter().getIR(opNode); + IRView ir = getBuilder().getCFAContextInterpreter().getIRView(opNode); SymbolTable symtab = ir.getSymbolTable(); DefUse du = getBuilder().getCFAContextInterpreter().getDU(opNode); PointerKey objKey = getBuilder().getPointerKeyForLocal(opNode, objVn); @@ -860,15 +899,15 @@ // log field access if (DEBUG_PROPERTIES) { if (isLoadOperation) - System.err.print(("adding read of " + objKey + "." + fieldKey + ":")); + System.err.print(("adding read of " + objKey + '.' + fieldKey + ':')); else - System.err.print(("adding write of " + objKey + "." + fieldKey + ":")); + System.err.print(("adding write of " + objKey + '.' + fieldKey + ':')); if (contentsAreInvariant(symtab, du, objVn)) { System.err.print(" constant obj:"); InstanceKey[] x = getInvariantContents(symtab, du, opNode, objVn); - for (int i = 0; i < x.length; i++) { - System.err.print((x[i].toString() + " ")); + for (InstanceKey element : x) { + System.err.print((element.toString() + ' ')); } } else { System.err.print((" obj:" + system.findOrCreatePointsToSet(objKey))); @@ -877,8 +916,8 @@ if (contentsAreInvariant(symtab, du, fieldsVn)) { System.err.print(" constant prop:"); InstanceKey[] x = getInvariantContents(symtab, du, opNode, fieldsVn); - for (int i = 0; i < x.length; i++) { - System.err.print((x[i].toString() + " ")); + for (InstanceKey element : x) { + System.err.print((element.toString() + ' ')); } } else { System.err.print((" props:" + system.findOrCreatePointsToSet(fieldKey))); @@ -890,14 +929,14 @@ // make sure instance keys get mapped for PointerAnalysisImpl if (contentsAreInvariant(symtab, du, objVn)) { InstanceKey[] x = getInvariantContents(symtab, du, opNode, objVn); - for (int i = 0; i < x.length; i++) { - system.findOrCreateIndexForInstanceKey(x[i]); + for (InstanceKey element : x) { + system.findOrCreateIndexForInstanceKey(element); } } if (contentsAreInvariant(symtab, du, fieldsVn)) { InstanceKey[] x = getInvariantContents(symtab, du, opNode, fieldsVn); - for (int i = 0; i < x.length; i++) { - system.findOrCreateIndexForInstanceKey(x[i]); + for (InstanceKey element : x) { + system.findOrCreateIndexForInstanceKey(element); } } @@ -935,7 +974,7 @@ protected void newFieldOperationFieldConstant(CGNode opNode, final boolean isLoadOperation, final ReflectedFieldAction action, final int objVn, final InstanceKey[] fieldsKeys) { - IR ir = getBuilder().getCFAContextInterpreter().getIR(opNode); + IRView ir = getBuilder().getCFAContextInterpreter().getIRView(opNode); SymbolTable symtab = ir.getSymbolTable(); DefUse du = getBuilder().getCFAContextInterpreter().getDU(opNode); PointerKey objKey = getBuilder().getPointerKeyForLocal(opNode, objVn); @@ -960,37 +999,31 @@ @Override public byte evaluate(PointsToSetVariable lhs, final PointsToSetVariable[] rhs) { - final IntSetVariable receivers = rhs[0]; - final IntSetVariable fields = rhs[1]; + final IntSetVariable receivers = rhs[0]; + final IntSetVariable fields = rhs[1]; if (receivers.getValue() != null && fields.getValue() != null) { - receivers.getValue().foreach(new IntSetAction() { - @Override - public void act(final int rptr) { - final InstanceKey receiver = system.getInstanceKey(rptr); + receivers.getValue().foreach(rptr -> { + final InstanceKey receiver = system.getInstanceKey(rptr); - if (!isLoadOperation) { - PointerKey cat = getPointerKeyForObjectCatalog(receiver); - if (cat != null) { - system.newConstraint(cat, assignOperator, fieldKey); - } + if (!isLoadOperation) { + PointerKey cat = getPointerKeyForObjectCatalog(receiver); + if (cat != null) { + system.newConstraint(cat, assignOperator, fieldKey); } + } - fields.getValue().foreach(new IntSetAction() { - @Override - public void act(int fptr) { - if (!doneField.contains(fptr) || !doneReceiver.contains(rptr)) { - InstanceKey field = system.getInstanceKey(fptr); - for (Iterator keys = isLoadOperation ? getPointerKeysForReflectedFieldRead(receiver, field) - : getPointerKeysForReflectedFieldWrite(receiver, field); keys.hasNext();) { - AbstractFieldPointerKey key = (AbstractFieldPointerKey) keys.next(); - if (DEBUG_PROPERTIES) - action.dump(key, false, false); - action.action(key); - } - } + fields.getValue().foreach(fptr -> { + if (!doneField.contains(fptr) || !doneReceiver.contains(rptr)) { + InstanceKey field = system.getInstanceKey(fptr); + for (PointerKey pkey : Iterator2Iterable.make(isLoadOperation ? getPointerKeysForReflectedFieldRead(receiver, field) + : getPointerKeysForReflectedFieldWrite(receiver, field))) { + AbstractFieldPointerKey key = (AbstractFieldPointerKey) pkey; + if (DEBUG_PROPERTIES) + action.dump(key, false, false); + action.action(key); } - }); - } + } + }); }); doneReceiver.addAll(receivers.getValue()); doneField.addAll(fields.getValue()); @@ -1021,31 +1054,28 @@ system.newSideEffect(new UnaryOperator() { @Override public byte evaluate(PointsToSetVariable lhs, PointsToSetVariable rhs) { - final IntSetVariable objects = rhs; + final IntSetVariable objects = rhs; if (objects.getValue() != null) { - objects.getValue().foreach(new IntSetAction() { - @Override - public void act(int optr) { - InstanceKey object = system.getInstanceKey(optr); - PointerKey objCatalog = getPointerKeyForObjectCatalog(object); - for (int f = 0; f < fieldsKeys.length; f++) { - if (isLoadOperation) { - for (Iterator keys = getPointerKeysForReflectedFieldRead(object, fieldsKeys[f]); keys.hasNext();) { - AbstractFieldPointerKey key = (AbstractFieldPointerKey) keys.next(); - if (DEBUG_PROPERTIES) - action.dump(key, true, false); - action.action(key); - } - } else { - if (objCatalog != null) { - system.newConstraint(objCatalog, fieldsKeys[f]); - } - for (Iterator keys = getPointerKeysForReflectedFieldWrite(object, fieldsKeys[f]); keys.hasNext();) { - AbstractFieldPointerKey key = (AbstractFieldPointerKey) keys.next(); - if (DEBUG_PROPERTIES) - action.dump(key, true, false); - action.action(key); - } + objects.getValue().foreach(optr -> { + InstanceKey object = system.getInstanceKey(optr); + PointerKey objCatalog = getPointerKeyForObjectCatalog(object); + for (InstanceKey fieldsKey : fieldsKeys) { + if (isLoadOperation) { + for (PointerKey pkey : Iterator2Iterable.make(getPointerKeysForReflectedFieldRead(object, fieldsKey))) { + AbstractFieldPointerKey key = (AbstractFieldPointerKey) pkey; + if (DEBUG_PROPERTIES) + action.dump(key, true, false); + action.action(key); + } + } else { + if (objCatalog != null) { + system.newConstraint(objCatalog, fieldsKey); + } + for (PointerKey pkey : Iterator2Iterable.make(getPointerKeysForReflectedFieldWrite(object, fieldsKey))) { + AbstractFieldPointerKey key = (AbstractFieldPointerKey) pkey; + if (DEBUG_PROPERTIES) + action.dump(key, true, false); + action.action(key); } } } @@ -1074,8 +1104,8 @@ protected void newFieldOperationOnlyObjectConstant(final boolean isLoadOperation, final ReflectedFieldAction action, final PointerKey fieldKey, final InstanceKey[] objKeys) { if (!isLoadOperation) { - for (int o = 0; o < objKeys.length; o++) { - PointerKey objCatalog = getPointerKeyForObjectCatalog(objKeys[o]); + for (InstanceKey objKey : objKeys) { + PointerKey objCatalog = getPointerKeyForObjectCatalog(objKey); if (objCatalog != null) { system.newConstraint(objCatalog, assignOperator, fieldKey); } @@ -1085,20 +1115,17 @@ system.newSideEffect(new UnaryOperator() { @Override public byte evaluate(PointsToSetVariable lhs, PointsToSetVariable rhs) { - final IntSetVariable fields = rhs; + final IntSetVariable fields = rhs; if (fields.getValue() != null) { - fields.getValue().foreach(new IntSetAction() { - @Override - public void act(int fptr) { - InstanceKey field = system.getInstanceKey(fptr); - for (int o = 0; o < objKeys.length; o++) { - for (Iterator keys = isLoadOperation ? getPointerKeysForReflectedFieldRead(objKeys[o], field) - : getPointerKeysForReflectedFieldWrite(objKeys[o], field); keys.hasNext();) { - AbstractFieldPointerKey key = (AbstractFieldPointerKey) keys.next(); - if (DEBUG_PROPERTIES) - action.dump(key, false, true); - action.action(key); - } + fields.getValue().foreach(fptr -> { + InstanceKey field = system.getInstanceKey(fptr); + for (InstanceKey objKey : objKeys) { + for (PointerKey pkey : Iterator2Iterable.make(isLoadOperation ? getPointerKeysForReflectedFieldRead(objKey, field) + : getPointerKeysForReflectedFieldWrite(objKey, field))) { + AbstractFieldPointerKey key = (AbstractFieldPointerKey) pkey; + if (DEBUG_PROPERTIES) + action.dump(key, false, true); + action.action(key); } } }); @@ -1125,22 +1152,22 @@ protected void newFieldOperationObjectAndFieldConstant(final boolean isLoadOperation, final ReflectedFieldAction action, final InstanceKey[] objKeys, InstanceKey[] fieldsKeys) { - for (int o = 0; o < objKeys.length; o++) { - PointerKey objCatalog = getPointerKeyForObjectCatalog(objKeys[o]); - for (int f = 0; f < fieldsKeys.length; f++) { + for (InstanceKey objKey : objKeys) { + PointerKey objCatalog = getPointerKeyForObjectCatalog(objKey); + for (InstanceKey fieldsKey : fieldsKeys) { if (isLoadOperation) { - for (Iterator keys = getPointerKeysForReflectedFieldRead(objKeys[o], fieldsKeys[f]); keys.hasNext();) { - AbstractFieldPointerKey key = (AbstractFieldPointerKey) keys.next(); + for (PointerKey pkey : Iterator2Iterable.make(getPointerKeysForReflectedFieldRead(objKey, fieldsKey))) { + AbstractFieldPointerKey key = (AbstractFieldPointerKey) pkey; if (DEBUG_PROPERTIES) action.dump(key, true, true); action.action(key); } } else { if (objCatalog != null) { - system.newConstraint(objCatalog, fieldsKeys[f]); + system.newConstraint(objCatalog, fieldsKey); } - for (Iterator keys = getPointerKeysForReflectedFieldWrite(objKeys[o], fieldsKeys[f]); keys.hasNext();) { - AbstractFieldPointerKey key = (AbstractFieldPointerKey) keys.next(); + for (PointerKey pkey : Iterator2Iterable.make(getPointerKeysForReflectedFieldWrite(objKey, fieldsKey))) { + AbstractFieldPointerKey key = (AbstractFieldPointerKey) pkey; if (DEBUG_PROPERTIES) action.dump(key, true, true); action.action(key); @@ -1151,7 +1178,7 @@ } public void newFieldWrite(CGNode opNode, int objVn, int fieldsVn, int rhsVn) { - IR ir = getBuilder().getCFAContextInterpreter().getIR(opNode); + IRView ir = getBuilder().getCFAContextInterpreter().getIRView(opNode); SymbolTable symtab = ir.getSymbolTable(); DefUse du = getBuilder().getCFAContextInterpreter().getDU(opNode); PointerKey rhsKey = getBuilder().getPointerKeyForLocal(opNode, rhsVn); @@ -1172,18 +1199,18 @@ @Override public void dump(AbstractFieldPointerKey fieldKey, boolean constObj, boolean constProp) { - System.err.println(("writing fixed rvals to " + fieldKey + " " + constObj + ", " + constProp)); - for (int i = 0; i < rhsFixedValues.length; i++) { - System.err.println(("writing " + rhsFixedValues[i])); + System.err.println(("writing fixed rvals to " + fieldKey + ' ' + constObj + ", " + constProp)); + for (InstanceKey rhsFixedValue : rhsFixedValues) { + System.err.println(("writing " + rhsFixedValue)); } } @Override public void action(AbstractFieldPointerKey fieldKey) { if (!representsNullType(fieldKey.getInstanceKey())) { - for (int i = 0; i < rhsFixedValues.length; i++) { - system.findOrCreateIndexForInstanceKey(rhsFixedValues[i]); - system.newConstraint(fieldKey, rhsFixedValues[i]); + for (InstanceKey rhsFixedValue : rhsFixedValues) { + system.findOrCreateIndexForInstanceKey(rhsFixedValue); + system.newConstraint(fieldKey, rhsFixedValue); } } } @@ -1206,7 +1233,7 @@ @Override public void dump(AbstractFieldPointerKey fieldKey, boolean constObj, boolean constProp) { - System.err.println(("write " + rhs + " to " + fieldKey + " " + constObj + ", " + constProp)); + System.err.println(("write " + rhs + " to " + fieldKey + ' ' + constObj + ", " + constProp)); } @Override @@ -1215,7 +1242,7 @@ system.newConstraint(fieldKey, assignOperator, rhs); } } - }; + } public void newFieldWrite(CGNode opNode, int objVn, int fieldsVn, final PointerKey rhs) { newFieldOperation(opNode, objVn, fieldsVn, false, new NormalWriter(rhs)); @@ -1233,7 +1260,7 @@ newFieldOperation(opNode, objVn, fieldsVn, true, new ReflectedFieldAction() { @Override public void dump(AbstractFieldPointerKey fieldKey, boolean constObj, boolean constProp) { - System.err.println(("read " + lhs + " from " + fieldKey + " " + constObj + ", " + constProp)); + System.err.println(("read " + lhs + " from " + fieldKey + ' ' + constObj + ", " + constProp)); } @Override diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CAstAnalysisScope.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CAstAnalysisScope.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CAstAnalysisScope.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CAstAnalysisScope.java 2019-01-29 17:08:39.000000000 +0000 @@ -10,14 +10,13 @@ package com.ibm.wala.cast.ipa.callgraph; import java.io.File; -import java.io.IOException; import java.util.Collection; import java.util.Collections; import com.ibm.wala.cast.loader.SingleClassLoaderFactory; import com.ibm.wala.classLoader.ArrayClassLoader; import com.ibm.wala.classLoader.Language; -import com.ibm.wala.classLoader.SourceModule; +import com.ibm.wala.classLoader.Module; import com.ibm.wala.ipa.callgraph.AnalysisScope; import com.ibm.wala.types.ClassLoaderReference; import com.ibm.wala.util.debug.Assertions; @@ -31,20 +30,18 @@ this.theLoader = loaders.getTheReference(); } - public CAstAnalysisScope(String[] sourceFileNames, SingleClassLoaderFactory loaders, Collection languages) - throws IOException { + public CAstAnalysisScope(String[] sourceFileNames, SingleClassLoaderFactory loaders, Collection languages) { this(loaders, languages); - for (int i = 0; i < sourceFileNames.length; i++) { - File F = new File(sourceFileNames[i]); + for (String sourceFileName : sourceFileNames) { + File F = new File(sourceFileName); addSourceFileToScope(theLoader, F, F.getPath()); } } - public CAstAnalysisScope(SourceModule[] sources, SingleClassLoaderFactory loaders, Collection languages) - throws IOException { + public CAstAnalysisScope(Module[] sources, SingleClassLoaderFactory loaders, Collection languages) { this(loaders, languages); - for (int i = 0; i < sources.length; i++) { - addToScope(theLoader, sources[i]); + for (Module source : sources) { + addToScope(theLoader, source); } } @@ -97,15 +94,11 @@ */ @Override public ClassLoaderReference getSyntheticLoader() { - Assertions.UNREACHABLE(); return null; } /** * Add a class file to the scope for a loader - * - * @param loader - * @param file */ @Override public void addClassFileToScope(ClassLoaderReference loader, File file) { @@ -113,7 +106,7 @@ } /** - * @return the ClassLoaderReference specified by name. + * @return the ClassLoaderReference specified by {@code name}. */ @Override public ClassLoaderReference getLoader(Atom name) { @@ -138,6 +131,6 @@ @Override public String toString() { - return super.toString() + "\n" + theLoader + ": " + getModules(theLoader); + return super.toString() + '\n' + theLoader + ": " + getModules(theLoader); } } diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CAstCallGraphUtil.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CAstCallGraphUtil.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CAstCallGraphUtil.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CAstCallGraphUtil.java 2019-01-29 17:08:39.000000000 +0000 @@ -16,25 +16,26 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.Collections; -import java.util.Iterator; - import org.apache.commons.io.ByteOrderMark; import org.apache.commons.io.input.BOMInputStream; import com.ibm.wala.cast.loader.SingleClassLoaderFactory; import com.ibm.wala.classLoader.IMethod; import com.ibm.wala.classLoader.Language; +import com.ibm.wala.classLoader.Module; import com.ibm.wala.classLoader.SourceFileModule; -import com.ibm.wala.classLoader.SourceModule; -import com.ibm.wala.ipa.callgraph.AnalysisCache; +import com.ibm.wala.ipa.callgraph.AnalysisCacheImpl; import com.ibm.wala.ipa.callgraph.AnalysisScope; import com.ibm.wala.ipa.callgraph.CGNode; import com.ibm.wala.ipa.callgraph.CallGraph; +import com.ibm.wala.ipa.callgraph.IAnalysisCacheView; import com.ibm.wala.ipa.callgraph.propagation.InstanceKey; import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis; import com.ibm.wala.ipa.callgraph.propagation.PointerKey; -import com.ibm.wala.ssa.IR; +import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter; import com.ibm.wala.ssa.IRFactory; +import com.ibm.wala.ssa.IRView; +import com.ibm.wala.util.collections.Iterator2Iterable; import com.ibm.wala.util.debug.Assertions; public class CAstCallGraphUtil { @@ -49,7 +50,7 @@ // URLs. It seems that, in DOS, URL.getFile() does not return a // \-separated file name, but rather one with /'s. Rather makes one // wonder why the function is called get_File_ :( - return makeSourceModule(script, dir + "/" + name); + return makeSourceModule(script, dir + '/' + name); } public static SourceFileModule makeSourceModule(URL script, String scriptName) { @@ -78,19 +79,18 @@ }; } - public static AnalysisScope makeScope(String[] files, SingleClassLoaderFactory loaders, Language language) throws IOException { + public static AnalysisScope makeScope(String[] files, SingleClassLoaderFactory loaders, Language language) { CAstAnalysisScope result = new CAstAnalysisScope(files, loaders, Collections.singleton(language)); return result; } - public static AnalysisScope makeScope(SourceModule[] files, SingleClassLoaderFactory loaders, Language language) - throws IOException { + public static AnalysisScope makeScope(Module[] files, SingleClassLoaderFactory loaders, Language language) { CAstAnalysisScope result = new CAstAnalysisScope(files, loaders, Collections.singleton(language)); return result; } - public static AnalysisCache makeCache(IRFactory factory) { - return new AnalysisCache(factory); + public static IAnalysisCacheView makeCache(IRFactory factory) { + return new AnalysisCacheImpl(factory); } public static String getShortName(CGNode nd) { @@ -110,7 +110,7 @@ if (s.indexOf('(') != -1) { String functionName = s.substring(s.indexOf('(') + 1, s.indexOf(')')); functionName = functionName.substring(functionName.lastIndexOf('/') + 1); - result += " " + functionName; + result += ' ' + functionName; } } result = "ctor of " + result; @@ -119,23 +119,22 @@ return result; } - public static void dumpCG(PointerAnalysis PA, CallGraph CG) { + public static void dumpCG(SSAContextInterpreter interp, PointerAnalysis PA, CallGraph CG) { if (AVOID_DUMP) return; - for (Iterator x = CG.iterator(); x.hasNext();) { - CGNode N = (CGNode) x.next(); + for (CGNode N : CG) { System.err.print("callees of node " + getShortName(N) + " : ["); boolean fst = true; - for (Iterator ns = CG.getSuccNodes(N); ns.hasNext();) { + for (CGNode n : Iterator2Iterable.make(CG.getSuccNodes(N))) { if (fst) fst = false; else System.err.print(", "); - System.err.print(getShortName(ns.next())); + System.err.print(getShortName(n)); } System.err.println("]"); System.err.println("\nIR of node " + N.getGraphNodeId() + ", context " + N.getContext()); - IR ir = N.getIR(); + IRView ir = interp.getIRView(N); if (ir != null) { System.err.println(ir); } else { @@ -144,8 +143,7 @@ } System.err.println("pointer analysis"); - for (Iterator x = PA.getPointerKeys().iterator(); x.hasNext();) { - PointerKey n = (PointerKey) x.next(); + for (PointerKey n : PA.getPointerKeys()) { try { System.err.println((n + " --> " + PA.getPointsToSet(n))); } catch (Throwable e) { diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageCallGraph.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageCallGraph.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageCallGraph.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageCallGraph.java 2019-01-29 17:08:39.000000000 +0000 @@ -19,18 +19,20 @@ import com.ibm.wala.classLoader.CallSiteReference; import com.ibm.wala.classLoader.IClass; import com.ibm.wala.classLoader.IMethod; -import com.ibm.wala.ipa.callgraph.AnalysisCache; import com.ibm.wala.ipa.callgraph.AnalysisOptions; import com.ibm.wala.ipa.callgraph.CGNode; +import com.ibm.wala.ipa.callgraph.IAnalysisCacheView; import com.ibm.wala.ipa.callgraph.impl.AbstractRootMethod; import com.ibm.wala.ipa.callgraph.impl.Everywhere; import com.ibm.wala.ipa.callgraph.impl.FakeRootMethod; import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.shrikeBT.IInvokeInstruction; import com.ibm.wala.ssa.SSAAbstractInvokeInstruction; -import com.ibm.wala.ssa.SSAInvokeInstruction; import com.ibm.wala.ssa.SSANewInstruction; +import com.ibm.wala.types.ClassLoaderReference; import com.ibm.wala.types.FieldReference; +import com.ibm.wala.types.MethodReference; +import com.ibm.wala.types.TypeName; import com.ibm.wala.types.TypeReference; import com.ibm.wala.util.CancelException; import com.ibm.wala.util.collections.HashMapFactory; @@ -49,9 +51,9 @@ */ public class CrossLanguageCallGraph extends AstCallGraph { - public CrossLanguageCallGraph(TargetLanguageSelector roots, IClassHierarchy cha, - AnalysisOptions options, AnalysisCache cache) { - super(cha, options, cache); + public CrossLanguageCallGraph(TargetLanguageSelector roots, IMethod fakeRootClass2, + AnalysisOptions options, IAnalysisCacheView cache) { + super(fakeRootClass2, options, cache); this.roots = roots; } @@ -91,14 +93,20 @@ return (AbstractRootMethod) languageRoots.get(language); } + public static ClassLoaderReference crossCoreLoader = ClassLoaderReference.Primordial; + + public static TypeReference fakeRootClass = TypeReference.findOrCreate(crossCoreLoader, TypeName.findOrCreate("CrossFakeRoot")); + + public static MethodReference rootMethod = MethodReference.findOrCreate(fakeRootClass, FakeRootMethod.name, FakeRootMethod.descr); + public class CrossLanguageFakeRoot extends ScriptFakeRoot { - public CrossLanguageFakeRoot(IClass declaringClass, IClassHierarchy cha, AnalysisOptions options, AnalysisCache cache) { - super(FakeRootMethod.rootMethod, declaringClass, cha, options, cache); + public CrossLanguageFakeRoot(IClass declaringClass, IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) { + super(rootMethod, declaringClass, cha, options, cache); } - public CrossLanguageFakeRoot(IClassHierarchy cha, AnalysisOptions options, AnalysisCache cache) { - super(FakeRootMethod.rootMethod, cha, options, cache); + public CrossLanguageFakeRoot(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) { + super(rootMethod, cha, options, cache); } public int addPhi(TypeReference type, int[] values) { @@ -138,14 +146,14 @@ } @Override - public SSAInvokeInstruction addInvocation(int[] params, CallSiteReference site) { + public SSAAbstractInvokeInstruction addInvocation(int[] params, CallSiteReference site) { TypeReference type = site.getDeclaredTarget().getDeclaringClass(); Atom language = type.getClassLoader().getLanguage(); AbstractRootMethod root = getLanguageRoot(language); return root.addInvocation(params, site); } - public SSAInvokeInstruction addInvocationInternal(int[] params, CallSiteReference site) { + public SSAAbstractInvokeInstruction addInvocationInternal(int[] params, CallSiteReference site) { return super.addInvocation(params, site); } @@ -165,7 +173,7 @@ } } - Iterator getLanguageRoots() { + Iterator getLanguageRoots() { return languageRootNodes.iterator(); } diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageClassTargetSelector.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageClassTargetSelector.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageClassTargetSelector.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageClassTargetSelector.java 2019-01-29 17:08:39.000000000 +0000 @@ -29,9 +29,9 @@ */ public class CrossLanguageClassTargetSelector implements ClassTargetSelector { - private final Map languageSelectors; + private final Map languageSelectors; - public CrossLanguageClassTargetSelector(Map languageSelectors) { + public CrossLanguageClassTargetSelector(Map languageSelectors) { this.languageSelectors = languageSelectors; } @@ -43,7 +43,7 @@ } private ClassTargetSelector getSelector(NewSiteReference site) { - return (ClassTargetSelector)languageSelectors.get(getLanguage(site)); + return languageSelectors.get(getLanguage(site)); } @Override diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageContextSelector.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageContextSelector.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageContextSelector.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageContextSelector.java 2019-01-29 17:08:39.000000000 +0000 @@ -35,9 +35,9 @@ */ public class CrossLanguageContextSelector implements ContextSelector { - private final Map languageSelectors; + private final Map languageSelectors; - public CrossLanguageContextSelector(Map languageSelectors) { + public CrossLanguageContextSelector(Map languageSelectors) { this.languageSelectors = languageSelectors; } @@ -50,7 +50,7 @@ } private ContextSelector getSelector(CallSiteReference site) { - return (ContextSelector)languageSelectors.get(getLanguage(site)); + return languageSelectors.get(getLanguage(site)); } @Override diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageMethodTargetSelector.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageMethodTargetSelector.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageMethodTargetSelector.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageMethodTargetSelector.java 2019-01-29 17:08:39.000000000 +0000 @@ -15,7 +15,6 @@ import com.ibm.wala.classLoader.CallSiteReference; import com.ibm.wala.classLoader.IClass; import com.ibm.wala.classLoader.IMethod; -import com.ibm.wala.classLoader.Language; import com.ibm.wala.ipa.callgraph.CGNode; import com.ibm.wala.ipa.callgraph.MethodTargetSelector; import com.ibm.wala.types.MethodReference; diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageSSAPropagationCallGraphBuilder.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageSSAPropagationCallGraphBuilder.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageSSAPropagationCallGraphBuilder.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageSSAPropagationCallGraphBuilder.java 2019-01-29 17:08:39.000000000 +0000 @@ -10,14 +10,13 @@ *******************************************************************************/ package com.ibm.wala.cast.ipa.callgraph; -import java.util.Iterator; - import com.ibm.wala.cast.ipa.callgraph.AstSSAPropagationCallGraphBuilder.AstPointerAnalysisImpl.AstImplicitPointsToSetVisitor; import com.ibm.wala.cast.util.TargetLanguageSelector; -import com.ibm.wala.ipa.callgraph.AnalysisCache; +import com.ibm.wala.classLoader.IMethod; import com.ibm.wala.ipa.callgraph.AnalysisOptions; import com.ibm.wala.ipa.callgraph.CGNode; import com.ibm.wala.ipa.callgraph.CallGraph; +import com.ibm.wala.ipa.callgraph.IAnalysisCacheView; import com.ibm.wala.ipa.callgraph.impl.AbstractRootMethod; import com.ibm.wala.ipa.callgraph.impl.ExplicitCallGraph; import com.ibm.wala.ipa.callgraph.propagation.InstanceKey; @@ -28,7 +27,6 @@ import com.ibm.wala.ipa.callgraph.propagation.PointsToMap; import com.ibm.wala.ipa.callgraph.propagation.PropagationCallGraphBuilder; import com.ibm.wala.ipa.callgraph.propagation.PropagationSystem; -import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.util.intset.MutableMapping; import com.ibm.wala.util.strings.Atom; @@ -47,16 +45,16 @@ protected abstract TargetLanguageSelector makeRootNodeSelector(); - protected CrossLanguageSSAPropagationCallGraphBuilder(IClassHierarchy cha, AnalysisOptions options, AnalysisCache cache, + protected CrossLanguageSSAPropagationCallGraphBuilder(IMethod fakeRootClass, AnalysisOptions options, IAnalysisCacheView cache, PointerKeyFactory pointerKeyFactory) { - super(cha, options, cache, pointerKeyFactory); + super(fakeRootClass, options, cache, pointerKeyFactory); visitors = makeMainVisitorSelector(); interesting = makeInterestingVisitorSelector(); } @Override - protected ExplicitCallGraph createEmptyCallGraph(IClassHierarchy cha, AnalysisOptions options) { - return new CrossLanguageCallGraph(makeRootNodeSelector(), cha, options, getAnalysisCache()); + protected ExplicitCallGraph createEmptyCallGraph(IMethod fakeRootClass, AnalysisOptions options) { + return new CrossLanguageCallGraph(makeRootNodeSelector(), fakeRootClass, options, getAnalysisCache()); } protected static Atom getLanguage(CGNode node) { @@ -65,7 +63,7 @@ @Override protected InterestingVisitor makeInterestingVisitor(CGNode node, int vn) { - return interesting.get(getLanguage(node), new Integer(vn)); + return interesting.get(getLanguage(node), Integer.valueOf(vn)); } @Override @@ -103,8 +101,8 @@ @Override protected void customInit() { - for (Iterator roots = ((CrossLanguageCallGraph) callGraph).getLanguageRoots(); roots.hasNext();) { - markDiscovered((CGNode) roots.next()); + for (CGNode root : callGraph) { + markDiscovered(root); } } diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/DelegatingAstPointerKeys.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/DelegatingAstPointerKeys.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/DelegatingAstPointerKeys.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/DelegatingAstPointerKeys.java 2019-01-29 17:08:39.000000000 +0000 @@ -76,10 +76,10 @@ @Override public Iterator getPointerKeysForReflectedFieldWrite(InstanceKey I, InstanceKey F) { - List result = new LinkedList(); + List result = new LinkedList<>(); if (F instanceof ConstantKey) { - PointerKey ifk = getInstanceFieldPointerKeyForConstant(I, (ConstantKey) F); + PointerKey ifk = getInstanceFieldPointerKeyForConstant(I, (ConstantKey) F); if (ifk != null) { result.add(ifk); } @@ -92,24 +92,19 @@ /** * get type for F appropriate for use in a field name. - * - * @param F - * @return */ protected IClass getFieldNameType(InstanceKey F) { return F.getConcreteType(); } /** - * if F is a supported constant representing a field, return the corresponding {@link InstanceFieldKey} for I. Otherwise, return null. - * @param F - * @return + * if F is a supported constant representing a field, return the corresponding {@link InstanceFieldKey} for I. Otherwise, return {@code null}. */ - protected PointerKey getInstanceFieldPointerKeyForConstant(InstanceKey I, ConstantKey F) { + protected PointerKey getInstanceFieldPointerKeyForConstant(InstanceKey I, ConstantKey F) { Object v = F.getValue(); // FIXME: current only constant string are handled - if (v instanceof String) { - IField f = I.getConcreteType().getField(Atom.findOrCreateUnicodeAtom((String) v)); + if (I.getConcreteType().getClassLoader().getLanguage().modelConstant(v)) { + IField f = I.getConcreteType().getField(Atom.findOrCreateUnicodeAtom(String.valueOf(v))); return getPointerKeyForInstanceField(I, f); } return null; @@ -118,11 +113,12 @@ @Override public Iterator getPointerKeysForReflectedFieldRead(InstanceKey I, InstanceKey F) { if (F instanceof ConstantKey) { - PointerKey ifk = getInstanceFieldPointerKeyForConstant(I, (ConstantKey) F); + PointerKey ifk = getInstanceFieldPointerKeyForConstant(I, (ConstantKey) F); if (ifk != null) { - return new NonNullSingletonIterator(ifk); + return new NonNullSingletonIterator<>(ifk); } } - return new NonNullSingletonIterator(ReflectedFieldPointerKey.mapped(new ConcreteTypeKey(getFieldNameType(F)), I)); + PointerKey x = ReflectedFieldPointerKey.mapped(new ConcreteTypeKey(getFieldNameType(F)), I); + return new NonNullSingletonIterator<>(x); } } diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/GlobalObjectKey.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/GlobalObjectKey.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/GlobalObjectKey.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/GlobalObjectKey.java 2019-01-29 17:08:39.000000000 +0000 @@ -23,8 +23,9 @@ /** * Represents the JavaScript global object. * - * @see JSSSAPropagationCallGraphBuilder + * @see com.ibm.wala.cast.js.ipa.callgraph.JSSSAPropagationCallGraphBuilder */ +@SuppressWarnings({"javadoc", "JavadocReference"}) public class GlobalObjectKey implements InstanceKey { private final IClass concreteType; diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/MiscellaneousHacksContextSelector.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/MiscellaneousHacksContextSelector.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/MiscellaneousHacksContextSelector.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/MiscellaneousHacksContextSelector.java 2019-01-29 17:08:39.000000000 +0000 @@ -10,7 +10,6 @@ *****************************************************************************/ package com.ibm.wala.cast.ipa.callgraph; -import java.util.Iterator; import java.util.Set; import com.ibm.wala.classLoader.CallSiteReference; @@ -46,8 +45,7 @@ basePolicy = base; specialPolicy = special; methodsToSpecialize = HashSetFactory.make(); - for (int i = 0; i < descriptors.length; i++) { - String[] descr = descriptors[i]; + for (String[] descr : descriptors) { switch (descr.length) { // loader name, loader language, classname, method name, method descr @@ -82,8 +80,8 @@ IClass klass = cha.lookupClass(TypeReference.findOrCreate(new ClassLoaderReference(Atom.findOrCreateUnicodeAtom(descr[0]), ClassLoaderReference.Java, null), TypeName.string2TypeName(descr[1]))); - for (Iterator M = klass.getDeclaredMethods().iterator(); M.hasNext();) { - methodsToSpecialize.add(((IMethod) M.next()).getReference()); + for (IMethod M : klass.getDeclaredMethods()) { + methodsToSpecialize.add(M.getReference()); } break; @@ -93,8 +91,8 @@ case 1: { IClass klass = cha.lookupClass(TypeReference.findOrCreate(ClassLoaderReference.Application, TypeName.string2TypeName(descr[0]))); - for (Iterator M = klass.getDeclaredMethods().iterator(); M.hasNext();) { - methodsToSpecialize.add(((IMethod) M.next()).getReference()); + for (IMethod M : klass.getDeclaredMethods()) { + methodsToSpecialize.add(M.getReference()); } break; diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/ObjectPropertyCatalogKey.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/ObjectPropertyCatalogKey.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/ObjectPropertyCatalogKey.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/ObjectPropertyCatalogKey.java 2019-01-29 17:08:39.000000000 +0000 @@ -37,7 +37,7 @@ @Override public String toString() { - return "[" + getName() + "]"; + return '[' + getName() + ']'; } public InstanceKey getObject() { diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/ReflectedFieldPointerKey.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/ReflectedFieldPointerKey.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/ReflectedFieldPointerKey.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/ReflectedFieldPointerKey.java 2019-01-29 17:08:39.000000000 +0000 @@ -47,7 +47,7 @@ } @Override - public String toString() { return "[" + getInstanceKey() + "; " + getFieldIdentifier() + "]"; } + public String toString() { return "[" + getInstanceKey() + "; " + getFieldIdentifier() + ']'; } public static ReflectedFieldPointerKey literal(final String lit, InstanceKey instance) { return new ReflectedFieldPointerKey(instance) { diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/ScopeMappingInstanceKeys.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/ScopeMappingInstanceKeys.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/ScopeMappingInstanceKeys.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/ScopeMappingInstanceKeys.java 2019-01-29 17:08:39.000000000 +0000 @@ -25,7 +25,6 @@ import com.ibm.wala.types.TypeReference; import com.ibm.wala.util.collections.CompoundIterator; import com.ibm.wala.util.collections.EmptyIterator; -import com.ibm.wala.util.Predicate; import com.ibm.wala.util.collections.FilterIterator; import com.ibm.wala.util.collections.NonNullSingletonIterator; import com.ibm.wala.util.collections.Pair; @@ -89,8 +88,6 @@ * get the CGNode representing the lexical parent of {@link #creator} with * name definer * - * @param definer - * @return */ public Iterator getFunargNodes(Pair name) { Collection constructorCallers = getConstructorCallers(this, name); @@ -98,12 +95,12 @@ Iterator result = EmptyIterator.instance(); for (CGNode callerOfConstructor : constructorCallers) { if (callerOfConstructor.getMethod().getReference().getDeclaringClass().getName().toString().equals(name.snd)) { - result = new CompoundIterator(result, new NonNullSingletonIterator(callerOfConstructor)); + result = new CompoundIterator<>(result, new NonNullSingletonIterator<>(callerOfConstructor)); } else { PointerKey funcKey = builder.getPointerKeyForLocal(callerOfConstructor, 1); for (InstanceKey funcPtr : builder.getPointerAnalysis().getPointsToSet(funcKey)) { if (funcPtr instanceof ScopeMappingInstanceKey) { - result = new CompoundIterator(result, ((ScopeMappingInstanceKey) funcPtr).getFunargNodes(name)); + result = new CompoundIterator<>(result, ((ScopeMappingInstanceKey) funcPtr).getFunargNodes(name)); } } } @@ -138,13 +135,9 @@ @Override public Iterator> getCreationSites(CallGraph CG) { - return new FilterIterator>( + return new FilterIterator<>( base.getCreationSites(CG), - new Predicate>() { - @Override public boolean test(Pair o) { - return o.fst.equals(creator); - } - }); + o -> o.fst.equals(creator)); } } diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/ScriptEntryPoints.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/ScriptEntryPoints.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/ScriptEntryPoints.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/ScriptEntryPoints.java 2019-01-29 17:08:39.000000000 +0000 @@ -26,12 +26,12 @@ public abstract class ScriptEntryPoints implements Iterable { - private final IClassHierarchy cha; + protected final IClassHierarchy cha; - private final IClass scriptType; + protected final IClass scriptType; - private class ScriptEntryPoint extends Entrypoint { - ScriptEntryPoint(IMethod scriptCodeBody) { + public class ScriptEntryPoint extends Entrypoint { + public ScriptEntryPoint(IMethod scriptCodeBody) { super(scriptCodeBody); } @@ -81,7 +81,7 @@ protected abstract CallSiteReference makeScriptSite(IMethod m, int pc); - protected boolean keep(IMethod method) { + protected boolean keep() { return true; } @@ -93,7 +93,7 @@ IClass cls = classes.next(); if (cha.isSubclassOf(cls, scriptType) && !cls.isAbstract()) { for (IMethod method : cls.getDeclaredMethods()) { - if (keep(method)) { + if (keep()) { ES.add(new ScriptEntryPoint(method)); } } @@ -107,7 +107,7 @@ IClass cls = cha.lookupClass(TypeReference.findOrCreate(scriptType.getClassLoader().getReference(), scriptName)); assert cls != null && cha.isSubclassOf(cls, scriptType) && !cls.isAbstract() : String.valueOf(cls) + " for " + scriptName; for (IMethod method : cls.getDeclaredMethods()) { - if (keep(method)) { + if (keep()) { return new ScriptEntryPoint(method); } } @@ -115,4 +115,4 @@ assert false; return null; } -} \ No newline at end of file +} diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/StandardFunctionTargetSelector.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/StandardFunctionTargetSelector.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/StandardFunctionTargetSelector.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/StandardFunctionTargetSelector.java 2019-01-29 17:08:39.000000000 +0000 @@ -19,7 +19,6 @@ import com.ibm.wala.ipa.callgraph.MethodTargetSelector; import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.types.ClassLoaderReference; -import com.ibm.wala.types.MethodReference; import com.ibm.wala.types.TypeReference; public class StandardFunctionTargetSelector implements MethodTargetSelector { @@ -27,6 +26,7 @@ private final MethodTargetSelector base; public StandardFunctionTargetSelector(IClassHierarchy cha, MethodTargetSelector base) { + assert cha != null; this.cha = cha; this.base = base; } @@ -66,11 +66,7 @@ } } - public boolean mightReturnSyntheticMethod(CGNode caller, CallSiteReference site) { - return true; - } - - public boolean mightReturnSyntheticMethod(MethodReference declaredTarget) { + public boolean mightReturnSyntheticMethod() { return true; } } diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/cha/CrossLanguageClassHierarchy.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/cha/CrossLanguageClassHierarchy.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/cha/CrossLanguageClassHierarchy.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/cha/CrossLanguageClassHierarchy.java 2019-01-29 17:08:39.000000000 +0000 @@ -22,8 +22,8 @@ import com.ibm.wala.classLoader.IMethod; import com.ibm.wala.classLoader.Language; import com.ibm.wala.ipa.callgraph.AnalysisScope; -import com.ibm.wala.ipa.cha.ClassHierarchy; import com.ibm.wala.ipa.cha.ClassHierarchyException; +import com.ibm.wala.ipa.cha.ClassHierarchyFactory; import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.types.ClassLoaderReference; import com.ibm.wala.types.FieldReference; @@ -101,11 +101,11 @@ @Override public IClassLoader[] getLoaders() { Set loaders = HashSetFactory.make(); - for (Iterator ldrs = analysisScope.getLoaders().iterator(); ldrs.hasNext();) { - loaders.add(getLoader((ClassLoaderReference) ldrs.next())); + for (ClassLoaderReference loaderReference : analysisScope.getLoaders()) { + loaders.add(getLoader(loaderReference)); } - return loaders.toArray(new IClassLoader[loaders.size()]); + return loaders.toArray(new IClassLoader[0]); } @Override @@ -121,8 +121,8 @@ @Override public int getNumberOfClasses() { int total = 0; - for (Iterator ldrs = analysisScope.getLoaders().iterator(); ldrs.hasNext();) { - total += getLoader((ClassLoaderReference) ldrs.next()).getNumberOfClasses(); + for (ClassLoaderReference loaderReference : analysisScope.getLoaders()) { + total += getLoader(loaderReference).getNumberOfClasses(); } return total; @@ -264,17 +264,17 @@ throws ClassHierarchyException { Set languages = scope.getBaseLanguages(); Map hierarchies = HashMapFactory.make(); - for (Iterator ls = languages.iterator(); ls.hasNext();) { - Language L = (Language) ls.next(); + for (Language L : languages) { Set ll = HashSetFactory.make(L.getDerivedLanguages()); ll.add(L); - hierarchies.put(L.getName(), ClassHierarchy.make(scope, factory, ll)); + hierarchies.put(L.getName(), ClassHierarchyFactory.make(scope, factory, ll)); } return new CrossLanguageClassHierarchy(scope, factory, hierarchies); } /** BEGIN Custom change: unresolved classes */ + @Override public Set getUnresolvedClasses() { return HashSetFactory.make(); } diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/lexical/LexicalModRef.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/lexical/LexicalModRef.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/lexical/LexicalModRef.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/lexical/LexicalModRef.java 2019-01-29 17:08:39.000000000 +0000 @@ -27,7 +27,6 @@ import com.ibm.wala.util.collections.HashSetFactory; import com.ibm.wala.util.collections.Iterator2Iterable; import com.ibm.wala.util.collections.Pair; -import com.ibm.wala.util.functions.Function; import com.ibm.wala.util.intset.OrdinalSet; /** @@ -56,13 +55,7 @@ */ public Map>> computeLexicalRef() { Map>> scan = CallGraphTransitiveClosure.collectNodeResults(cg, - new Function>>() { - - @Override - public Collection> apply(CGNode n) { - return scanNodeForLexReads(n); - } - }); + this::scanNodeForLexReads); return CallGraphTransitiveClosure.transitiveClosure(cg, scan); } @@ -73,13 +66,7 @@ */ public Map>> computeLexicalMod() { Map>> scan = CallGraphTransitiveClosure.collectNodeResults(cg, - new Function>>() { - - @Override - public Collection> apply(CGNode n) { - return scanNodeForLexWrites(n); - } - }); + this::scanNodeForLexWrites); return CallGraphTransitiveClosure.transitiveClosure(cg, scan); } diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/modref/AstModRef.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/modref/AstModRef.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/modref/AstModRef.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/modref/AstModRef.java 2019-01-29 17:08:39.000000000 +0000 @@ -21,6 +21,8 @@ import com.ibm.wala.cast.ir.ssa.AstIsDefinedInstruction; import com.ibm.wala.cast.ir.ssa.AstLexicalRead; import com.ibm.wala.cast.ir.ssa.AstLexicalWrite; +import com.ibm.wala.cast.ir.ssa.AstPropertyRead; +import com.ibm.wala.cast.ir.ssa.AstPropertyWrite; import com.ibm.wala.cast.ir.ssa.EachElementGetInstruction; import com.ibm.wala.cast.ir.ssa.EachElementHasNextInstruction; import com.ibm.wala.ipa.callgraph.CGNode; @@ -29,11 +31,12 @@ import com.ibm.wala.ipa.callgraph.propagation.PointerKey; import com.ibm.wala.ipa.modref.ExtendedHeapModel; import com.ibm.wala.ipa.modref.ModRef; +import com.ibm.wala.util.collections.Iterator2Iterable; public class AstModRef extends ModRef { @Override - public ExtendedHeapModel makeHeapModel(PointerAnalysis pa) { + public ExtendedHeapModel makeHeapModel(PointerAnalysis pa) { return (AstHeapModel)pa.getHeapModel(); } @@ -44,6 +47,25 @@ } @Override + public void visitPropertyRead(AstPropertyRead instruction) { + PointerKey obj = h.getPointerKeyForLocal(n, instruction.getObjectRef()); + PointerKey prop = h.getPointerKeyForLocal(n, instruction.getMemberRef()); + for(InstanceKey o : pa.getPointsToSet(obj)) { + for(InstanceKey p : pa.getPointsToSet(prop)) { + for(PointerKey x : Iterator2Iterable.make(h.getPointerKeysForReflectedFieldRead(o, p))) { + assert x != null : instruction; + result.add(x); + } + } + } + } + + @Override + public void visitPropertyWrite(AstPropertyWrite instruction) { + // do nothing + } + + @Override public void visitAstLexicalRead(AstLexicalRead instruction) { } @@ -90,8 +112,8 @@ } @Override - protected RefVisitor makeRefVisitor(CGNode n, Collection result, PointerAnalysis pa, ExtendedHeapModel h) { - return new AstRefVisitor(n, result, pa, (AstHeapModel)h); + protected RefVisitor makeRefVisitor(CGNode n, Collection result, PointerAnalysis pa, ExtendedHeapModel h) { + return new AstRefVisitor<>(n, result, pa, (AstHeapModel)h); } protected static class AstModVisitor @@ -147,11 +169,30 @@ public void visitEcho(AstEchoInstruction inst) { } + + @Override + public void visitPropertyRead(AstPropertyRead instruction) { + // do nothing + } + + @Override + public void visitPropertyWrite(AstPropertyWrite instruction) { + PointerKey obj = h.getPointerKeyForLocal(n, instruction.getObjectRef()); + PointerKey prop = h.getPointerKeyForLocal(n, instruction.getMemberRef()); + for(T o : pa.getPointsToSet(obj)) { + for(T p : pa.getPointsToSet(prop)) { + for(PointerKey x : Iterator2Iterable.make(h.getPointerKeysForReflectedFieldWrite(o, p))) { + assert x != null : instruction; + result.add(x); + } + } + } + } } @Override - protected ModVisitor makeModVisitor(CGNode n, Collection result, PointerAnalysis pa, ExtendedHeapModel h, boolean ignoreAllocHeapDefs) { - return new AstModVisitor(n, result, (AstHeapModel)h, pa); + protected ModVisitor makeModVisitor(CGNode n, Collection result, PointerAnalysis pa, ExtendedHeapModel h, boolean ignoreAllocHeapDefs) { + return new AstModVisitor<>(n, result, (AstHeapModel)h, pa); } } diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/cfg/AstInducedCFG.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/cfg/AstInducedCFG.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/cfg/AstInducedCFG.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/cfg/AstInducedCFG.java 2019-01-29 17:08:39.000000000 +0000 @@ -18,6 +18,8 @@ import com.ibm.wala.cast.ir.ssa.AstIsDefinedInstruction; import com.ibm.wala.cast.ir.ssa.AstLexicalRead; import com.ibm.wala.cast.ir.ssa.AstLexicalWrite; +import com.ibm.wala.cast.ir.ssa.AstPropertyRead; +import com.ibm.wala.cast.ir.ssa.AstPropertyWrite; import com.ibm.wala.cast.ir.ssa.EachElementGetInstruction; import com.ibm.wala.cast.ir.ssa.EachElementHasNextInstruction; import com.ibm.wala.cfg.InducedCFG; @@ -38,6 +40,14 @@ } @Override + public void visitPropertyRead(AstPropertyRead inst) { + } + + @Override + public void visitPropertyWrite(AstPropertyWrite inst) { + } + + @Override public void visitAstLexicalRead(AstLexicalRead inst) { } @@ -86,6 +96,14 @@ } @Override + public void visitPropertyRead(AstPropertyRead inst) { + } + + @Override + public void visitPropertyWrite(AstPropertyWrite inst) { + } + + @Override public void visitAstLexicalRead(AstLexicalRead inst) { } diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/cfg/Util.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/cfg/Util.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/cfg/Util.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/cfg/Util.java 2019-01-29 17:08:39.000000000 +0000 @@ -10,19 +10,20 @@ *****************************************************************************/ package com.ibm.wala.cast.ir.cfg; -import java.util.Iterator; - import com.ibm.wala.cfg.ControlFlowGraph; import com.ibm.wala.cfg.IBasicBlock; +import com.ibm.wala.util.collections.Iterator2Iterable; import com.ibm.wala.util.debug.Assertions; public class Util { public static > int whichPred(ControlFlowGraph CFG, T Y, T X) { int i = 0; - for (Iterator N = CFG.getPredNodes(Y); N.hasNext(); i++) - if (N.next() == X) + for (Object N : Iterator2Iterable.make(CFG.getPredNodes(Y))) { + if (N == X) return i; + ++i; + } Assertions.UNREACHABLE(); return -1; diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AbstractReflectiveGet.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AbstractReflectiveGet.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AbstractReflectiveGet.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AbstractReflectiveGet.java 2019-01-29 17:08:39.000000000 +0000 @@ -34,7 +34,7 @@ } /** - * @see com.ibm.wala.ssa.Instruction#getDef() + * @see com.ibm.wala.ssa.SSAInstruction#getDef() */ @Override public boolean hasDef() { @@ -52,7 +52,7 @@ } /** - * @see com.ibm.wala.ssa.Instruction#getNumberOfUses() + * @see com.ibm.wala.ssa.SSAInstruction#getNumberOfUses() */ @Override public int getNumberOfUses() { diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AbstractReflectivePut.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AbstractReflectivePut.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AbstractReflectivePut.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AbstractReflectivePut.java 2019-01-29 17:08:39.000000000 +0000 @@ -34,7 +34,7 @@ } /** - * @see com.ibm.wala.ssa.Instruction#getDef() + * @see com.ibm.wala.ssa.SSAInstruction#getDef() */ @Override public int getDef() { @@ -42,7 +42,7 @@ } /** - * @see com.ibm.wala.ssa.Instruction#getNumberOfUses() + * @see com.ibm.wala.ssa.SSAInstruction#getNumberOfUses() */ @Override public int getNumberOfUses() { diff -Nru wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AbstractSSAConversion.java wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AbstractSSAConversion.java --- wala-1.3.9/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AbstractSSAConversion.java 2016-05-10 12:59:26.000000000 +0000 +++ wala-1.5.1/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AbstractSSAConversion.java 2019-01-29 17:08:39.000000000 +0000 @@ -10,11 +10,11 @@ *****************************************************************************/ package com.ibm.wala.cast.ir.ssa; -import java.util.EmptyStackException; +import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.Set; -import java.util.Stack; import com.ibm.wala.ssa.IR; import com.ibm.wala.ssa.ISSABasicBlock; @@ -27,6 +27,7 @@ import com.ibm.wala.ssa.SymbolTable; import com.ibm.wala.util.collections.ArrayIterator; import com.ibm.wala.util.collections.IntStack; +import com.ibm.wala.util.collections.Iterator2Iterable; import com.ibm.wala.util.graph.Graph; import com.ibm.wala.util.graph.dominators.DominanceFrontiers; @@ -38,7 +39,7 @@ * several integral portions of the traditional algorithm: *