This commit is contained in:
Julian Dolby 2013-06-25 11:57:37 -04:00
parent 3015d1c5f9
commit 080325b5f6
644 changed files with 4956 additions and 195 deletions

View File

@ -31,6 +31,7 @@ public class Activator extends Plugin {
*
* @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
*/
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
@ -41,6 +42,7 @@ public class Activator extends Plugin {
*
* @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
*/
@Override
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);

View File

@ -23,6 +23,7 @@ public class PolyglotJLexTest extends JLexTest {
@Override
protected JavaSourceAnalysisEngine getAnalysisEngine(final String[] mainClassDescriptors, Collection<String> sources, List<String> libs) {
JavaSourceAnalysisEngine engine = new PolyglotJavaSourceAnalysisEngine() {
@Override
protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha, new String[] { "LJLex/Main" });
}

View File

@ -28,6 +28,7 @@ public class PolyglotJavaIRTest extends JavaIRTests {
@Override
protected AbstractAnalysisEngine getAnalysisEngine(final String[] mainClassDescriptors, Collection<String> sources, List<String> libs) {
JavaSourceAnalysisEngine engine = new PolyglotJavaSourceAnalysisEngine() {
@Override
protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha, mainClassDescriptors);
}

View File

@ -26,15 +26,19 @@ import com.ibm.wala.ipa.cha.IClassHierarchy;
public class PolyglotSyncDuplicatorTest extends SyncDuplicatorTest {
@Override
protected JavaSourceAnalysisEngine getAnalysisEngine(final String[] mainClassDescriptors, Collection<String> sources, List<String> libs) {
JavaSourceAnalysisEngine engine = new PolyglotJavaSourceAnalysisEngine() {
@Override
protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha, mainClassDescriptors);
}
@Override
public IRTranslatorExtension getTranslatorExtension() {
JavaIRTranslatorExtension ext = new JavaIRTranslatorExtension();
ext.setCAstRewriterFactory(new CAstRewriterFactory() {
@Override
public CAstRewriter createCAstRewriter(CAst ast) {
return new SynchronizedBlockDuplicator(ast, true, testMethod);
}

View File

@ -32,6 +32,7 @@ public class AscriptionGoal extends VisitorGoal {
public AscriptionGoal(Job job) {
super(job,
new AscriptionVisitor(job, job.extensionInfo().typeSystem(), job.extensionInfo().nodeFactory()) {
@Override
public Expr ascribe(Expr e, Type toType) throws SemanticException {
if (e instanceof ArrayInit && e.type().isNull()) {
return e.type(toType);

View File

@ -66,6 +66,7 @@ public class IRGoal extends SourceGoal_c /* PORT1.7 removed 'implements EndGoal'
return true;
}
@Override
public String name() {
return "<WALA IR goal for " + job.source().path() + ">";
}

View File

@ -52,11 +52,13 @@ public class JavaIRTranslatorExtension extends JLExtensionInfo implements IRTran
};
}
@Override
public void setSourceLoader(PolyglotSourceLoaderImpl sourceLoader) {
fSourceLoader= sourceLoader;
fMapper= new PolyglotIdentityMapper(sourceLoader.getReference());
}
@Override
public PolyglotIdentityMapper getIdentityMapper() {
return fMapper;
}
@ -65,10 +67,12 @@ public class JavaIRTranslatorExtension extends JLExtensionInfo implements IRTran
rewriterFactory = factory;
}
@Override
public CAstRewriterFactory<?,?> getCAstRewriterFactory() {
return rewriterFactory;
}
@Override
public boolean getReplicateForDoLoops() {
return false;
}

View File

@ -37,14 +37,17 @@ public class ModuleSource extends FileSource {
public ModuleSource(final SourceModule module) throws IOException {
super(new Resource() {
@Override
public File file() {
return new File(module.getURL().getFile());
}
@Override
public InputStream getInputStream() throws IOException {
return module.getInputStream();
}
@Override
public String name() {
String fullPath = module.getURL().getFile();
int idx= fullPath.lastIndexOf(File.separatorChar);

View File

@ -43,6 +43,7 @@ public class PolyglotClassLoaderFactory extends ClassLoaderFactoryImpl {
return fExtensionMap.get(clr);
}
@Override
protected IClassLoader makeNewClassLoader(ClassLoaderReference classLoaderReference, IClassHierarchy cha, IClassLoader parent,
AnalysisScope scope) throws IOException {
if (classLoaderReference.equals(JavaSourceAnalysisScope.SOURCE)) {

View File

@ -62,6 +62,7 @@ public class PolyglotIdentityMapper implements IdentityMapper<Type, CodeInstance
fClassLoaderRef= clr;
}
@Override
public FieldReference getFieldRef(FieldInstance field) {
if (!fFieldMap.containsKey(field)) {
FieldReference ref= referenceForField(field);
@ -71,6 +72,7 @@ public class PolyglotIdentityMapper implements IdentityMapper<Type, CodeInstance
return fFieldMap.get(field);
}
@Override
public TypeReference getTypeRef(Type type) {
if (!fTypeMap.containsKey(type)) {
TypeReference ref= referenceForType(type);
@ -80,6 +82,7 @@ public class PolyglotIdentityMapper implements IdentityMapper<Type, CodeInstance
return fTypeMap.get(type);
}
@Override
public MethodReference getMethodRef(CodeInstance method) {
if (!fMethodMap.containsKey(method)) {
MethodReference sel= referenceForMethod(method);

View File

@ -20,6 +20,7 @@ public class PolyglotJavaSourceAnalysisEngine extends JavaSourceAnalysisEngine {
return new JavaIRTranslatorExtension();
}
@Override
protected ClassLoaderFactory getClassLoaderFactory(SetOfClasses exclusions) {
return new PolyglotClassLoaderFactory(exclusions, getTranslatorExtension());
}

View File

@ -36,6 +36,7 @@ public class PolyglotSourceLoaderImpl extends JavaSourceLoaderImpl {
return fExtInfo;
}
@Override
protected SourceModuleTranslator getTranslator() {
return new PolyglotSourceModuleTranslator(cha.getScope(), fExtInfo, this, JavaSourceAnalysisScope.SOURCE);
}

View File

@ -108,6 +108,7 @@ public class PolyglotSourceModuleTranslator implements SourceModuleTranslator {
fSourcePath = ".";
}
@Override
public void loadAllSources(Set<ModuleEntry> modules) {
Options opts= fExtInfo.getOptions();
opts.assertions = true;

View File

@ -42,18 +42,22 @@ public class PolyglotTypeDictionary extends CAstTypeDictionaryImpl {
fEltCAstType = getCAstTypeFor(fEltPolyglotType);
}
@Override
public int getNumDimensions() {
return 1; // always 1 for Java
}
@Override
public CAstType getElementType() {
return fEltCAstType;
}
@Override
public String getName() {
return "[" + fEltCAstType.getName();
}
@Override
public Collection<CAstType> getSupertypes() {
if (fEltPolyglotType.isPrimitive())
return Collections.singleton(getCAstTypeFor(fTypeSystem.Object()));
@ -81,6 +85,7 @@ public class PolyglotTypeDictionary extends CAstTypeDictionaryImpl {
fTranslator = translator;
}
@Override
public CAstType getCAstTypeFor(Object astType) {
CAstType type = super.getCAstTypeFor(astType);
// Handle the case where we haven't seen an AST decl for some type before

View File

@ -24,9 +24,11 @@ public class PolyglotUnwoundIRTranslatorExtension
this.unrollDepth = unrollDepth;
}
@Override
public CAstRewriterFactory<CAstRewriter.RewriteContext<AstLoopUnwinder.UnwindKey>,AstLoopUnwinder.UnwindKey> getCAstRewriterFactory() {
return new CAstRewriterFactory<CAstRewriter.RewriteContext<AstLoopUnwinder.UnwindKey>,AstLoopUnwinder.UnwindKey>() {
public AstLoopUnwinder createCAstRewriter(CAst ast) {
@Override
public AstLoopUnwinder createCAstRewriter(CAst ast) {
return new AstLoopUnwinder(ast, true, unrollDepth);
}
};

View File

@ -1,5 +1,10 @@
eclipse.preferences.version=1
instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true
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.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
@ -11,18 +16,23 @@ org.eclipse.jdt.core.compiler.doc.comment.support=enabled
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
org.eclipse.jdt.core.compiler.problem.deadCode=ignore
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.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
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.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
@ -33,44 +43,67 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
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.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.missingOverrideAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
org.eclipse.jdt.core.compiler.problem.nullReference=warning
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
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.unusedObjectAllocation=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
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.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false

View File

@ -19,8 +19,10 @@ public class AnonymousClass {
Foo f= new Foo() {
int value = 3;
public int getValue() { return value; }
public int getValueBase() { return value - base.intValue(); }
public int getValue() { return value; }
public int getValueBase() { return value - base.intValue(); }
};
System.out.println(f.getValue());
@ -35,19 +37,22 @@ public class AnonymousClass {
abstract class FooImpl implements Foo {
int y;
public abstract int getValue();
public abstract int getValue();
FooImpl(int _y) {
y = _y;
}
public int getValueBase() {
public int getValueBase() {
return y + getValue() - base.intValue();
}
}
Foo f= new FooImpl(-4) {
public int getValue() { return 7; }
public int getValue() { return 7; }
};
System.out.println(f.getValue());

View File

@ -21,7 +21,8 @@ public class FunkySupers {
}
class SubFunkySupers extends FunkySupers {
int funky(FunkySupers fs) {
int funky(FunkySupers fs) {
SubFunkySupers.super.funky(fs);
SubFunkySupers.this.funky(fs);
SubFunkySupers.this.y = 7;

View File

@ -29,9 +29,11 @@ class Base {
}
}
class Derived extends Base {
public void foo() {
super.foo();
}
public String bar(int x) {
return Integer.toHexString(x);
}

View File

@ -31,7 +31,8 @@ public class InnerClassLexicalReads {
* 0 v2:com.ibm.wala.ssa.SymbolTable$1@16b18b6 = lexical:y@LInnerClassLexicalReads/makeIntConstant(I)LIntConstant;
* 1 return v2:com.ibm.wala.ssa.SymbolTable$1@16b18b6[11:4] -> [11:13]
*/
public int getConstant() {
public int getConstant() {
return y;
}
};

View File

@ -25,6 +25,7 @@ class FooIT1 implements IFoo {
public FooIT1(char ch) {
fValue= ch;
}
public char getValue() {
return fValue;
}

View File

@ -29,6 +29,7 @@ abstract class PrimitiveWrapper {
* {@inheritDoc}
* @see java.lang.Object#equals(java.lang.Object)
*/
abstract public boolean equals(Object o);
}
@ -47,6 +48,7 @@ final class IntWrapper extends PrimitiveWrapper {
* {@inheritDoc}
* @see com.ibm.miniatur.tests.sequential.PrimitiveWrapper#intValue()
*/
public int intValue() {
return val;
}
@ -55,6 +57,7 @@ final class IntWrapper extends PrimitiveWrapper {
* {@inheritDoc}
* @see com.ibm.miniatur.tests.sequential.PrimitiveWrapper#setIntValue(int)
*/
public void setIntValue(int i) {
this.val = i;
}
@ -63,6 +66,7 @@ final class IntWrapper extends PrimitiveWrapper {
* {@inheritDoc}
* @see com.ibm.miniatur.tests.sequential.PrimitiveWrapper#equals(java.lang.Object)
*/
public boolean equals(Object o) {
return o instanceof IntWrapper && ((IntWrapper)o).val==val;
}

View File

@ -13,7 +13,8 @@ interface ISimpleCalls {
public void helloWorld();
}
public class SimpleCalls implements ISimpleCalls {
public void helloWorld() {
public void helloWorld() {
System.out.println("hello world!");
}
public int anotherCall() {

View File

@ -13,6 +13,7 @@ class R implements Runnable {
R(int i) { this.i = i; }
public void run() {
return;
}

View File

@ -55,7 +55,8 @@ public class SimpleNames {
final int i = 5;
new Object() {
public int hashCode() {
public int hashCode() {
f = 5; // SimpleNames.this = 5
s = 6; // SimpleNames.s = 6

View File

@ -76,7 +76,7 @@ public class ConstructorsAndInitializers extends Super {
iX = 55 + 12;
}
public String toString() {
public String toString() {
return s + " -- from an anon class in " + iX + "," + sX + ": " + ConstructorsAndInitializers.this.s;
}

View File

@ -45,7 +45,7 @@ public class InnerClasses extends Temp {
Object supportLocalBusiness() {
final int x = 54;
class FooBar {
public int hashCode() { return x; }
public int hashCode() { return x; }
}
return new FooBar();
}
@ -53,7 +53,7 @@ public class InnerClasses extends Temp {
static Object anonymousCoward() {
final int x = 5;
return new Object() {
public int hashCode() { return x; }
public int hashCode() { return x; }
};
}
@ -64,7 +64,7 @@ public class InnerClasses extends Temp {
System.out.println(anonymousCoward().hashCode());
final String xx = "crazy";
Outie outie = new Outie("weird") {
public String toString() {
public String toString() {
return "bogus" + x + xx + xxxx;
}
};

View File

@ -95,7 +95,7 @@ public class MethodMadness {
return 13 + x;
}
protected int protectedInteger() {
protected int protectedInteger() {
return 233 + x;
}

View File

@ -44,7 +44,8 @@ public class AnonGeneNullarySimple {
}
static class StrTripler implements Ops<String> {
public String nullary() {
public String nullary() {
String x = "talk about it ";
return x+x+x;
}

View File

@ -48,10 +48,12 @@ public class AnonymousGenerics {
// if has type parameters, find overriding method and
// get erasures for all of those types and make a new method
// that calls this one (with casts). no worries about return values.
public String unary(String x) {
public String unary(String x) {
return x + x + x;
}
public String nullary() {
public String nullary() {
String x = "talk about it ";
return x+x+x;
}
@ -63,10 +65,12 @@ public class AnonymousGenerics {
private void doit() {
Ops<String> strQuadrupler = new Ops<String>() {
public String unary(String x) {
public String unary(String x) {
return x+x+x+x;
}
public String nullary() {
public String nullary() {
String x = "time to make a move to the global economy ";
return x+x+x+x;
}

View File

@ -42,9 +42,11 @@ public class Cocovariant {
A foo(String x) { return null; }
}
static class B extends A {
B foo(String x) { return null; }
}
static class C extends B {
C foo(String x) { return null; }
}
public static void main(String[] args) {

View File

@ -51,14 +51,16 @@ interface IGeneric<E> {
class ConcreteGeneric<Q> implements IGeneric<Q> {
Q x;
public Q bar(Q a, Q b) {
public Q bar(Q a, Q b) {
x = a;
if (b.hashCode() == a.hashCode() || b.toString().equals(a.toString()))
return a;
return b;
}
public Q foo() {
public Q foo() {
return x;
}
}
@ -68,7 +70,8 @@ class ConcreteGeneric2<Q> extends ConcreteGeneric<Q> {
public void setFoo(Q a) {
y = a;
}
public Q foo() {
public Q foo() {
return y;
}
}

View File

@ -45,16 +45,19 @@ public class GenericMemberClasses<T>
{
T x = null;
private int localChangeID;
public boolean hasNext() {
public boolean hasNext() {
return ( localChangeID == 5 );
}
public T next() {
public T next() {
localChangeID = 5;
return x;
}
public void remove() {
public void remove() {
}
}
public static void main(String args[]) {

View File

@ -47,13 +47,15 @@ public class MoreOverriddenGenerics {
}
class Sub extends Super<Number> {
public Number get() {
public Number get() {
return super.get();
}
}
class SubSub extends Sub {
public Long get() {
public Long get() {
return new Long(6);
}
}

View File

@ -39,10 +39,14 @@ package javaonepointfive;
public class NotSoSimpleEnums {
public enum Direction {
NORTH("nord") { public Direction getOpposite() { return SOUTH; }},
EAST("est") { public Direction getOpposite() { return WEST; }},
SOUTH("sud") { public Direction getOpposite() { return NORTH; }},
WEST("ouest") { public Direction getOpposite() { return EAST; }};
NORTH("nord") {
public Direction getOpposite() { return SOUTH; }},
EAST("est") {
public Direction getOpposite() { return WEST; }},
SOUTH("sud") {
public Direction getOpposite() { return NORTH; }},
WEST("ouest") {
public Direction getOpposite() { return EAST; }};
public abstract Direction getOpposite();

View File

@ -43,7 +43,8 @@ public class OverridesOnePointFour {
}
static class Sub implements Super {
public Long get() {
public Long get() {
return new Long(6);
}
}

View File

@ -46,7 +46,8 @@ public class VarargsCovariant {
}
static class B extends A {
B hello(int... x) {
B hello(int... x) {
System.out.println("b hello");
return this;
}

View File

@ -69,7 +69,8 @@ class VarityTestSuper {
}
class VarityTestSub extends VarityTestSuper {
void bar(String... args) {}
void bar(String... args) {}
}
public class VarargsOverriding {

View File

@ -18,6 +18,7 @@ public abstract class JLexTest extends IRTests {
super(null);
}
@Override
protected String singleJavaInputForTest() {
return "JLex";
}
@ -26,6 +27,7 @@ public abstract class JLexTest extends IRTests {
runTest(singleTestSrc(), rtJar, new String[] { "LJLex/Main" }, emptyList, false);
}
@Override
protected String singleJavaPkgInputForTest(String pkgName) {
return "";
}

View File

@ -84,6 +84,7 @@ public abstract class JavaIRTests extends IRTests {
new IRAssertion() {
@Override
public void check(CallGraph cg) {
final String typeStr = singleInputForTest();
@ -115,6 +116,7 @@ public abstract class JavaIRTests extends IRTests {
*/
new IRAssertion() {
@Override
public void check(CallGraph cg) {
final String typeStr = "IFoo";
@ -132,6 +134,7 @@ public abstract class JavaIRTests extends IRTests {
*/
new IRAssertion() {
@Override
public void check(CallGraph cg) {
final String typeStr = "FooIT1";
@ -157,6 +160,7 @@ public abstract class JavaIRTests extends IRTests {
*/
new IRAssertion() {
@Override
public void check(CallGraph cg) {
final String typeStr = "Derived";
@ -186,6 +190,7 @@ public abstract class JavaIRTests extends IRTests {
*/
new IRAssertion() {
@Override
public void check(CallGraph cg) {
MethodReference mref = descriptorToMethodRef("Source#Array1#foo#()V", cg.getClassHierarchy());
@ -215,6 +220,7 @@ public abstract class JavaIRTests extends IRTests {
*/
new IRAssertion() {
@Override
public void check(CallGraph cg) {
MethodReference mref = descriptorToMethodRef("Source#ArrayLiteral1#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
@ -236,6 +242,7 @@ public abstract class JavaIRTests extends IRTests {
*/
new IRAssertion() {
@Override
public void check(CallGraph cg) {
MethodReference mref = descriptorToMethodRef("Source#ArrayLiteral2#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
@ -297,6 +304,7 @@ public abstract class JavaIRTests extends IRTests {
*/
new IRAssertion() {
@Override
public void check(CallGraph cg) {
MethodReference mref = descriptorToMethodRef("Source#QualifiedStatic#main#([Ljava/lang/String;)V", cg.getClassHierarchy());
@ -319,6 +327,7 @@ public abstract class JavaIRTests extends IRTests {
new IRAssertion() {
@Override
public void check(CallGraph cg) {
final String typeStr = singleInputForTest() + "$WhatsIt";
@ -349,6 +358,7 @@ public abstract class JavaIRTests extends IRTests {
new IRAssertion() {
@Override
public void check(CallGraph cg) {
final String typeStr = singleInputForTest();
@ -465,6 +475,7 @@ public abstract class JavaIRTests extends IRTests {
* Classes local to method are enclosed in the class the methods belong
* to.
*/
@Override
public void check(CallGraph cg) {
final String typeStr = singleInputForTest();
final String localClassStr = "Foo";
@ -501,6 +512,7 @@ public abstract class JavaIRTests extends IRTests {
new IRAssertion() {
@Override
public void check(CallGraph cg) {
final String typeStr = singleInputForTest();

View File

@ -31,14 +31,16 @@ public class TestPlugin extends Plugin {
/**
* This method is called upon plug-in activation
*/
public void start(BundleContext context) throws Exception {
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
}
/**
* This method is called when the plug-in is stopped
*/
public void stop(BundleContext context) throws Exception {
@Override
public void stop(BundleContext context) throws Exception {
super.stop(context);
plugin = null;
}

View File

@ -31,14 +31,16 @@ public class JavaSourcePlugin extends Plugin {
/**
* This method is called upon plug-in activation
*/
public void start(BundleContext context) throws Exception {
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
}
/**
* This method is called when the plug-in is stopped
*/
public void stop(BundleContext context) throws Exception {
@Override
public void stop(BundleContext context) throws Exception {
super.stop(context);
plugin = null;
}

View File

@ -36,6 +36,7 @@ public class AstJavaTypeInference extends AstTypeInference {
protected IClass stringClass;
protected class AstJavaTypeOperatorFactory extends AstTypeOperatorFactory implements AstJavaInstructionVisitor {
@Override
public void visitBinaryOp(SSABinaryOpInstruction instruction) {
if (doPrimitives) {
IBinaryOpInstruction.IOperator op = instruction.getOperator();
@ -48,6 +49,7 @@ public class AstJavaTypeInference extends AstTypeInference {
}
}
@Override
public void visitEnclosingObjectReference(EnclosingObjectReference inst) {
TypeReference type = inst.getEnclosingType();
IClass klass = cha.lookupClass(type);
@ -58,6 +60,7 @@ public class AstJavaTypeInference extends AstTypeInference {
}
}
@Override
public void visitJavaInvoke(AstJavaInvokeInstruction instruction) {
TypeReference type = instruction.getDeclaredResultType();
if (type.isReferenceType()) {
@ -81,6 +84,7 @@ public class AstJavaTypeInference extends AstTypeInference {
public class AstJavaTypeVarFactory extends TypeVarFactory {
@Override
public IVariable makeVariable(int valueNumber) {
SymbolTable st = ir.getSymbolTable();
if (st.isStringConstant(valueNumber)) {
@ -105,10 +109,12 @@ public class AstJavaTypeInference extends AstTypeInference {
return stringClass;
}
@Override
protected void initialize() {
init(ir, new AstJavaTypeVarFactory(), new AstJavaTypeOperatorFactory());
}
@Override
public TypeAbstraction getConstantPrimitiveType(int valueNumber) {
SymbolTable st = ir.getSymbolTable();
if (st.isBooleanConstant(valueNumber)) {
@ -123,6 +129,7 @@ public class AstJavaTypeInference extends AstTypeInference {
private PrimAndStringOp() {
}
@Override
public byte evaluate(TypeVariable lhs, TypeVariable[] rhs) {
TypeAbstraction meet = null;
@ -164,6 +171,7 @@ public class AstJavaTypeInference extends AstTypeInference {
*
* @see com.ibm.wala.dataflow.Operator#hashCode()
*/
@Override
public int hashCode() {
return 71292;
}
@ -173,6 +181,7 @@ public class AstJavaTypeInference extends AstTypeInference {
*
* @see com.ibm.wala.dataflow.Operator#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
return o != null && o.getClass().equals(getClass());
}

View File

@ -86,6 +86,7 @@ public abstract class JavaSourceAnalysisEngine extends AbstractAnalysisEngine {
systemEntries.add(M);
}
@Override
protected void addApplicationModulesToScope() {
ClassLoaderReference app = scope.getApplicationLoader();
for (Module M : userEntries) {
@ -99,6 +100,7 @@ public abstract class JavaSourceAnalysisEngine extends AbstractAnalysisEngine {
}
}
@Override
public void buildAnalysisScope() throws IOException {
scope = makeSourceAnalysisScope();
@ -120,6 +122,7 @@ public abstract class JavaSourceAnalysisEngine extends AbstractAnalysisEngine {
protected abstract ClassLoaderFactory getClassLoaderFactory(SetOfClasses exclusions);
@Override
public IClassHierarchy buildClassHierarchy() {
IClassHierarchy cha = null;
ClassLoaderFactory factory = getClassLoaderFactory(scope.getExclusions());
@ -134,6 +137,7 @@ public abstract class JavaSourceAnalysisEngine extends AbstractAnalysisEngine {
return cha;
}
@Override
protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha);
}
@ -143,11 +147,13 @@ public abstract class JavaSourceAnalysisEngine extends AbstractAnalysisEngine {
return new AnalysisCache(AstIRFactory.makeDefaultFactory());
}
@Override
public AnalysisOptions getDefaultOptions(Iterable<Entrypoint> entrypoints) {
AnalysisOptions options = new AnalysisOptions(getScope(), entrypoints);
SSAOptions ssaOptions = new SSAOptions();
ssaOptions.setDefaultValues(new SSAOptions.DefaultValues() {
@Override
public int getDefaultValue(SymbolTable symtab, int valueNumber) {
return symtab.getDefaultValue(valueNumber);
}

View File

@ -61,19 +61,23 @@ public class SynchronizedBlockDuplicator extends
this.testDirection = testDirection;
}
@Override
public int hashCode() {
return (testDirection ? 1 : -1) * System.identityHashCode(syncNode) * (rest == null ? 1 : rest.hashCode());
}
@Override
public UnwindKey parent() {
return rest;
}
@Override
public boolean equals(Object o) {
return (o instanceof UnwindKey) && ((UnwindKey) o).testDirection == testDirection && ((UnwindKey) o).syncNode == syncNode
&& (rest == null ? ((UnwindKey) o).rest == null : rest.equals(((UnwindKey) o).rest));
}
@Override
public String toString() {
return "#" + testDirection + ((rest == null) ? "" : rest.toString());
}
@ -101,6 +105,7 @@ public class SynchronizedBlockDuplicator extends
*/
private static class RootContext implements RewriteContext<UnwindKey> {
@Override
public UnwindKey key() {
return null;
}
@ -131,6 +136,7 @@ public class SynchronizedBlockDuplicator extends
this.parent = parent;
}
@Override
public UnwindKey key() {
return new UnwindKey(testDirection, syncNode, parent.key());
}
@ -150,6 +156,7 @@ public class SynchronizedBlockDuplicator extends
}
}
@Override
protected CAstNode flowOutTo(Map nodeMap, CAstNode oldSource, Object label, CAstNode oldTarget, CAstControlFlowMap orig,
CAstSourcePositionMap src) {
assert oldTarget == CAstControlFlowMap.EXCEPTION_TO_EXIT;
@ -196,6 +203,7 @@ public class SynchronizedBlockDuplicator extends
return null;
}
@Override
protected CAstNode copyNodes(CAstNode n, final CAstControlFlowMap cfg, RewriteContext<UnwindKey> c, Map<Pair<CAstNode, UnwindKey>, CAstNode> nodeMap) {
String varName;
// don't copy operators or constants (presumably since they are immutable?)

View File

@ -51,6 +51,7 @@ public class AstJavaSSAPropagationCallGraphBuilder extends AstSSAPropagationCall
//
// ///////////////////////////////////////////////////////////////////////////
@Override
protected boolean useObjectCatalog() {
return false;
}
@ -69,10 +70,12 @@ public class AstJavaSSAPropagationCallGraphBuilder extends AstSSAPropagationCall
this.outer = outer;
}
@Override
public int hashCode() {
return getInstanceKey().hashCode() * outer.hashCode();
}
@Override
public boolean equals(Object o) {
return (o instanceof EnclosingObjectReferenceKey) && ((EnclosingObjectReferenceKey) o).outer.equals(outer)
&& ((EnclosingObjectReferenceKey) o).getInstanceKey().equals(getInstanceKey());
@ -109,15 +112,18 @@ public class AstJavaSSAPropagationCallGraphBuilder extends AstSSAPropagationCall
super(vn);
}
@Override
public void visitEnclosingObjectReference(EnclosingObjectReference inst) {
Assertions.UNREACHABLE();
}
@Override
public void visitJavaInvoke(AstJavaInvokeInstruction instruction) {
bingo = true;
}
}
@Override
protected InterestingVisitor makeInterestingVisitor(CGNode node, int vn) {
return new AstJavaInterestingVisitor(vn);
}
@ -166,10 +172,12 @@ public class AstJavaSSAPropagationCallGraphBuilder extends AstSSAPropagationCall
} else {
system.newSideEffect(new UnaryOperator<PointsToSetVariable>() {
@Override
public byte evaluate(PointsToSetVariable lhs, PointsToSetVariable rhs) {
IntSetVariable tv = (IntSetVariable) rhs;
if (tv.getValue() != null) {
tv.getValue().foreach(new IntSetAction() {
@Override
public void act(int ptr) {
InstanceKey iKey = system.getInstanceKey(ptr);
PointerKey enclosing = new EnclosingObjectReferenceKey(iKey, cls);
@ -180,14 +188,17 @@ public class AstJavaSSAPropagationCallGraphBuilder extends AstSSAPropagationCall
return NOT_CHANGED;
}
@Override
public int hashCode() {
return System.identityHashCode(this);
}
@Override
public boolean equals(Object o) {
return o == this;
}
@Override
public String toString() {
return "enclosing objects of " + objKey;
}
@ -195,6 +206,7 @@ public class AstJavaSSAPropagationCallGraphBuilder extends AstSSAPropagationCall
}
}
@Override
public void visitEnclosingObjectReference(EnclosingObjectReference inst) {
PointerKey lvalKey = getPointerKeyForLocal(inst.getDef());
PointerKey objKey = getPointerKeyForLocal(1);
@ -202,6 +214,7 @@ public class AstJavaSSAPropagationCallGraphBuilder extends AstSSAPropagationCall
handleEnclosingObject(lvalKey, cls, objKey);
}
@Override
public void visitNew(SSANewInstruction instruction) {
super.visitNew(instruction);
InstanceKey iKey = getInstanceKeyForAllocation(instruction.getNewSite());
@ -272,11 +285,13 @@ public class AstJavaSSAPropagationCallGraphBuilder extends AstSSAPropagationCall
}
}
@Override
public void visitJavaInvoke(AstJavaInvokeInstruction instruction) {
visitInvokeInternal(instruction, new DefaultInvariantComputer());
}
}
@Override
protected ConstraintVisitor makeVisitor(CGNode node) {
return new AstJavaConstraintVisitor(this, node);
}

View File

@ -72,6 +72,7 @@ public class JavaScopeMappingInstanceKeys extends ScopeMappingInstanceKeys {
return cls instanceof JavaClass;
}
@Override
protected boolean needsScopeMappingKey(InstanceKey base) {
boolean result = getParents(base).length > 0;
if (AstTranslator.DEBUG_LEXICAL)

View File

@ -49,6 +49,7 @@ public class JavaSourceAnalysisScope extends AnalysisScope {
return SOURCE;
}
@Override
public void addToScope(ClassLoaderReference loader, Module m) {
if (m instanceof SourceDirectoryTreeModule && loader.equals(ClassLoaderReference.Application)) {
super.addToScope(SOURCE, m);

View File

@ -32,16 +32,19 @@ public class AstJavaModRef extends AstModRef {
super(n, result, pa, h);
}
@Override
public void visitJavaInvoke(AstJavaInvokeInstruction instruction) {
}
@Override
public void visitEnclosingObjectReference(EnclosingObjectReference inst) {
}
}
@Override
protected RefVisitor makeRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis pa, ExtendedHeapModel h) {
return new AstJavaRefVisitor(n, result, pa, h);
}
@ -56,10 +59,12 @@ public class AstJavaModRef extends AstModRef {
}
@Override
public void visitJavaInvoke(AstJavaInvokeInstruction instruction) {
}
@Override
public void visitEnclosingObjectReference(EnclosingObjectReference inst) {
}

View File

@ -77,6 +77,7 @@ public class AstJavaSlicer extends Slicer {
public static Set<Statement> gatherAssertions(CallGraph CG, Collection<CGNode> partialRoots) {
return gatherStatements(CG, partialRoots, new Filter<SSAInstruction>() {
@Override
public boolean accepts(SSAInstruction o) {
return o instanceof AstAssertInstruction;
}
@ -85,6 +86,7 @@ public class AstJavaSlicer extends Slicer {
public static Set<Statement> gatherMonitors(CallGraph CG, Collection<CGNode> partialRoots) {
return gatherStatements(CG, partialRoots, new Filter<SSAInstruction>() {
@Override
public boolean accepts(SSAInstruction o) {
return o instanceof SSAMonitorInstruction;
}
@ -93,6 +95,7 @@ public class AstJavaSlicer extends Slicer {
public static Set<Statement> gatherWrites(CallGraph CG, Collection<CGNode> partialRoots) {
return gatherStatements(CG, partialRoots, new Filter<SSAInstruction>() {
@Override
public boolean accepts(SSAInstruction o) {
return (o instanceof SSAPutInstruction) || (o instanceof SSAArrayStoreInstruction);
}
@ -101,6 +104,7 @@ public class AstJavaSlicer extends Slicer {
public static Set<Statement> gatherReads(CallGraph CG, Collection<CGNode> partialRoots) {
return gatherStatements(CG, partialRoots, new Filter<SSAInstruction>() {
@Override
public boolean accepts(SSAInstruction o) {
return (o instanceof SSAGetInstruction) || (o instanceof SSAArrayLoadInstruction);
}

View File

@ -108,14 +108,17 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
this.annotations = annotations;
}
@Override
public Collection<Annotation> getAnnotations() {
return annotations;
}
@Override
public IClassHierarchy getClassHierarchy() {
return cha;
}
@Override
public IClass getSuperclass() {
boolean excludedSupertype=false;
for (Iterator iter = superTypeNames.iterator(); iter.hasNext();) {
@ -143,6 +146,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
return null;
}
@Override
public Collection<IClass> getDirectInterfaces() {
List<IClass> result = new ArrayList<IClass>();
for (Iterator iter = superTypeNames.iterator(); iter.hasNext();) {
@ -177,6 +181,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
return enclosingClass;
}
@Override
public String toString() {
StringBuffer sb = new StringBuffer("<src-class: " );
sb.append(getName().toString());
@ -264,6 +269,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
return 0;
}
@Override
public TypeReference getParameterType(int i) {
return parameterTypes[i];
}
@ -290,6 +296,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
return types;
}
@Override
public TypeReference[] getDeclaredExceptions() {
return exceptionTypes;
}
@ -308,6 +315,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
return result;
}
@Override
public String toString() {
return "<src-method: " + this.getReference() + ">";
}
@ -324,20 +332,24 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
super(methodEntity, owner);
}
@Override
public String getLocalVariableName(int bcIndex, int localNumber) {
Assertions.UNREACHABLE("AbstractJavaMethod.getLocalVariableName() called");
return null;
}
@Override
public boolean hasLocalVariableTable() {
Assertions.UNREACHABLE("AbstractJavaMethod.hasLocalVariableTable() called");
return false;
}
@Override
public LexicalParent[] getParents() {
return new LexicalParent[0];
}
@Override
public IClassHierarchy getClassHierarchy() {
return cha;
}
@ -355,18 +367,22 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
super(methodEntity, owner, cfg, symtab, hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, debugInfo);
}
@Override
public IClassHierarchy getClassHierarchy() {
return cha;
}
@Override
public String getLocalVariableName(int bcIndex, int localNumber) {
return null;
}
@Override
public boolean hasLocalVariableTable() {
return false;
}
@Override
public LexicalParent[] getParents() {
if (AstTranslator.DEBUG_LEXICAL) {
System.err.println(("resolving parents of " + this));
@ -409,10 +425,12 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
final int hack = i;
result[i] = new LexicalParent() {
@Override
public String getName() {
return parents[hack];
}
@Override
public AstMethod getMethod() {
return (AstMethod) cls.getMethod(sel);
}
@ -467,12 +485,14 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
return cha;
}
@Override
protected void loadAllSources(Set<ModuleEntry> modules) {
getTranslator().loadAllSources(modules);
}
protected abstract SourceModuleTranslator getTranslator();
@Override
public void init(List<Module> modules) throws IOException {
super.init(modules);
fTypeMap = null;
@ -513,97 +533,120 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
return javaClass;
}
@Override
public String toString() {
return "Java Source Loader (classes " + loadedClasses.values() + ")";
}
public static class InstructionFactory extends JavaInstructionFactory implements AstJavaInstructionFactory {
@Override
public com.ibm.wala.cast.java.ssa.EnclosingObjectReference EnclosingObjectReference(int lval, TypeReference type) {
return new EnclosingObjectReference(lval, type);
}
@Override
public AstJavaNewEnclosingInstruction JavaNewEnclosingInstruction(int result, NewSiteReference site, int enclosing) {
return new AstJavaNewEnclosingInstruction(result, site, enclosing);
}
@Override
public AstJavaInvokeInstruction JavaInvokeInstruction(int result, int[] params, int exception, CallSiteReference site) {
return new AstJavaInvokeInstruction(result, params, exception, site);
}
@Override
public AstJavaInvokeInstruction JavaInvokeInstruction(int[] params, int exception, CallSiteReference site) {
return new AstJavaInvokeInstruction(params, exception, site);
}
@Override
public AstJavaInvokeInstruction JavaInvokeInstruction(int[] results, int[] params, int exception, CallSiteReference site,
Access[] lexicalReads, Access[] lexicalWrites) {
return new AstJavaInvokeInstruction(results, params, exception, site, lexicalReads, lexicalWrites);
}
@Override
public AstAssertInstruction AssertInstruction(int value, boolean fromSpecification) {
return new AstAssertInstruction(value, fromSpecification);
}
@Override
public com.ibm.wala.cast.ir.ssa.AssignInstruction AssignInstruction(int result, int val) {
return new AssignInstruction(result, val);
}
@Override
public com.ibm.wala.cast.ir.ssa.EachElementGetInstruction EachElementGetInstruction(int value, int objectRef) {
throw new UnsupportedOperationException();
}
@Override
public com.ibm.wala.cast.ir.ssa.EachElementHasNextInstruction EachElementHasNextInstruction(int value, int objectRef) {
throw new UnsupportedOperationException();
}
@Override
public AstEchoInstruction EchoInstruction(int[] rvals) {
throw new UnsupportedOperationException();
}
@Override
public AstGlobalRead GlobalRead(int lhs, FieldReference global) {
throw new UnsupportedOperationException();
}
@Override
public AstGlobalWrite GlobalWrite(FieldReference global, int rhs) {
throw new UnsupportedOperationException();
}
@Override
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, int fieldVal, FieldReference fieldRef) {
throw new UnsupportedOperationException();
}
@Override
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, FieldReference fieldRef) {
throw new UnsupportedOperationException();
}
@Override
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, int fieldVal) {
throw new UnsupportedOperationException();
}
@Override
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval) {
throw new UnsupportedOperationException();
}
@Override
public AstLexicalRead LexicalRead(Access[] accesses) {
return new AstLexicalRead(accesses);
}
@Override
public AstLexicalRead LexicalRead(Access access) {
return new AstLexicalRead(access);
}
@Override
public AstLexicalRead LexicalRead(int lhs, String definer, String globalName) {
return new AstLexicalRead(lhs, definer, globalName);
}
@Override
public AstLexicalWrite LexicalWrite(Access[] accesses) {
return new AstLexicalWrite(accesses);
}
@Override
public AstLexicalWrite LexicalWrite(Access access) {
return new AstLexicalWrite(access);
}
@Override
public AstLexicalWrite LexicalWrite(String definer, String globalName, int rhs) {
return new AstLexicalWrite(definer, globalName, rhs);
}
@ -615,6 +658,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
private static final InstructionFactory insts = new InstructionFactory();
@Override
public InstructionFactory getInstructionFactory() {
return insts;
}

View File

@ -17,10 +17,12 @@ public class AstJavaAbstractInstructionVisitor
implements AstJavaInstructionVisitor
{
@Override
public void visitJavaInvoke(AstJavaInvokeInstruction instruction) {
}
@Override
public void visitEnclosingObjectReference(EnclosingObjectReference inst) {
}

View File

@ -51,6 +51,7 @@ public class AstJavaInvokeInstruction extends FixedParametersLexicalInvokeInstru
super(results, params, exception, site, lexicalReads, lexicalWrites);
}
@Override
protected SSAInstruction copyInstruction(SSAInstructionFactory insts, int results[], int[] params, int exception,
Access[] lexicalReads, Access[] lexicalWrites) {
return ((AstJavaInstructionFactory) insts).JavaInvokeInstruction(results, params, exception, getCallSite(), lexicalReads,
@ -60,6 +61,7 @@ public class AstJavaInvokeInstruction extends FixedParametersLexicalInvokeInstru
/**
* @see com.ibm.domo.ssa.SSAInstruction#visit(IVisitor)
*/
@Override
public void visit(IVisitor v) {
((AstJavaInstructionVisitor) v).visitJavaInvoke(this);
}
@ -69,6 +71,7 @@ public class AstJavaInvokeInstruction extends FixedParametersLexicalInvokeInstru
*
* @see com.ibm.domo.ssa.Instruction#getExceptionTypes()
*/
@Override
public Collection<TypeReference> getExceptionTypes() {
return JavaLanguage.getNullPointerException();
}

View File

@ -24,10 +24,12 @@ public class AstJavaNewEnclosingInstruction extends SSANewInstruction {
int enclosing;
@Override
public int getNumberOfUses() {
return 1;
}
@Override
public int getUse(int i) {
assert i == 0;
return enclosing;
@ -42,14 +44,17 @@ public class AstJavaNewEnclosingInstruction extends SSANewInstruction {
return this.enclosing;
}
@Override
public String toString() {
return super.toString() + " ENCLOSING v" + enclosing;
}
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((AstJavaInstructionFactory)insts).JavaNewEnclosingInstruction(defs==null? getDef(0): defs[0], getNewSite(), uses==null? enclosing: uses[0]);
}
@Override
public Collection<TypeReference> getExceptionTypes() {
return JavaLanguage.getNewScalarExceptions();
}

View File

@ -35,20 +35,24 @@ public class EnclosingObjectReference extends SSAInstruction {
this.type = type;
}
@Override
public boolean hasDef() {
return true;
}
@Override
public int getDef() {
return lval;
}
@Override
public int getDef(int i) {
assert i == 0;
return lval;
}
@Override
public int getNumberOfDefs() {
return 1;
}
@ -57,26 +61,32 @@ public class EnclosingObjectReference extends SSAInstruction {
return type;
}
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((AstJavaInstructionFactory) insts).EnclosingObjectReference(defs == null ? lval : defs[0], type);
}
@Override
public String toString(SymbolTable symbolTable) {
return getValueString(symbolTable, lval) + " = enclosing " + type.getName();
}
@Override
public void visit(IVisitor v) {
((AstJavaInstructionVisitor) v).visitEnclosingObjectReference(this);
}
@Override
public int hashCode() {
return lval * type.hashCode();
}
@Override
public Collection<TypeReference> getExceptionTypes() {
return Collections.emptySet();
}
@Override
public boolean isFallThrough() {
return true;
}

View File

@ -64,6 +64,7 @@ public class JavaCAst2IRTranslator extends AstTranslator {
return (JavaSourceLoaderImpl) loader;
}
@Override
protected boolean useDefaultInitValues() {
return true;
}
@ -71,35 +72,42 @@ public class JavaCAst2IRTranslator extends AstTranslator {
// Java does not have standalone global variables, and let's not
// adopt the nasty JavaScript practice of creating globals without
// explicit definitions
@Override
protected boolean hasImplicitGlobals() {
return false;
}
@Override
protected TypeReference defaultCatchType() {
return TypeReference.JavaLangThrowable;
}
@Override
protected TypeReference makeType(CAstType type) {
return TypeReference.findOrCreate(loader.getReference(), TypeName.string2TypeName(type.getName()));
}
// Java globals are disguised as fields (statics), so we should never
// ask this question when parsing Java code
@Override
protected boolean treatGlobalsAsLexicallyScoped() {
Assertions.UNREACHABLE();
return false;
}
@Override
protected void doThrow(WalkContext context, int exception) {
context.cfg().addInstruction(insts.ThrowInstruction(exception));
}
@Override
public void doArrayRead(WalkContext context, int result, int arrayValue, CAstNode arrayRefNode, int[] dimValues) {
TypeReference arrayTypeRef = (TypeReference) arrayRefNode.getChild(1).getValue();
context.cfg().addInstruction(insts.ArrayLoadInstruction(result, arrayValue, dimValues[0], arrayTypeRef));
processExceptions(arrayRefNode, context);
}
@Override
public void doArrayWrite(WalkContext context, int arrayValue, CAstNode arrayRefNode, int[] dimValues, int rval) {
TypeReference arrayTypeRef = arrayRefNode.getKind() == CAstNode.ARRAY_LITERAL ? ((TypeReference) arrayRefNode.getChild(0)
.getChild(0).getValue()).getArrayElementType() : (TypeReference) arrayRefNode.getChild(1).getValue();
@ -109,6 +117,7 @@ public class JavaCAst2IRTranslator extends AstTranslator {
processExceptions(arrayRefNode, context);
}
@Override
protected void doFieldRead(WalkContext context, int result, int receiver, CAstNode elt, CAstNode parent) {
// elt is a constant CAstNode whose value is a FieldReference.
FieldReference fieldRef = (FieldReference) elt.getValue();
@ -122,6 +131,7 @@ public class JavaCAst2IRTranslator extends AstTranslator {
}
}
@Override
protected void doFieldWrite(WalkContext context, int receiver, CAstNode elt, CAstNode parent, int rval) {
FieldReference fieldRef = (FieldReference) elt.getValue();
@ -134,11 +144,13 @@ public class JavaCAst2IRTranslator extends AstTranslator {
}
}
@Override
protected void doMaterializeFunction(CAstNode n, WalkContext context, int result, int exception, CAstEntity fn) {
// Not possible in Java (no free-standing functions)
Assertions.UNREACHABLE("Real functions in Java??? I don't think so!");
}
@Override
protected void doNewObject(WalkContext context, CAstNode newNode, int result, Object type, int[] arguments) {
TypeReference typeRef = (TypeReference) type;
@ -169,6 +181,7 @@ public class JavaCAst2IRTranslator extends AstTranslator {
}
}
@Override
protected void doCall(WalkContext context, CAstNode call, int result, int exception, CAstNode name, int receiver, int[] arguments) {
assert name.getKind() == CAstNode.CONSTANT;
CallSiteReference dummySiteRef = (CallSiteReference) name.getValue();
@ -193,10 +206,12 @@ public class JavaCAst2IRTranslator extends AstTranslator {
Assertions.UNREACHABLE("doGlobalRead() called for Java code???");
}
@Override
protected void doGlobalWrite(WalkContext context, String name, int rval) {
Assertions.UNREACHABLE("doGlobalWrite() called for Java code???");
}
@Override
protected void defineField(CAstEntity topEntity, WalkContext definingContext, CAstEntity n) {
assert topEntity.getKind() == CAstEntity.TYPE_ENTITY;
assert n.getKind() == CAstEntity.FIELD_ENTITY;
@ -214,6 +229,7 @@ public class JavaCAst2IRTranslator extends AstTranslator {
// handles abstract method declarations, which do not get defineFunction
// called for them
@Override
protected void declareFunction(CAstEntity N, WalkContext definingContext) {
CAstType.Method methodType = (Method) N.getType();
CAstType owningType = methodType.getDeclaringType();
@ -226,6 +242,7 @@ public class JavaCAst2IRTranslator extends AstTranslator {
((JavaSourceLoaderImpl) loader).defineAbstractFunction(N, owner);
}
@Override
protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG cfg, SymbolTable symtab,
boolean hasCatchBlock, Map<IBasicBlock,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo,
DebuggingInformation debugInfo) {
@ -247,11 +264,13 @@ public class JavaCAst2IRTranslator extends AstTranslator {
debugInfo);
}
@Override
protected void doPrimitive(int resultVal, WalkContext context, CAstNode primitiveCall) {
// For now, no-op (no primitives in normal Java code)
Assertions.UNREACHABLE("doPrimitive() called for Java code???");
}
@Override
protected String composeEntityName(WalkContext parent, CAstEntity f) {
switch (f.getKind()) {
case CAstEntity.TYPE_ENTITY: {
@ -295,6 +314,7 @@ public class JavaCAst2IRTranslator extends AstTranslator {
}
}
@Override
protected boolean defineType(CAstEntity type, WalkContext wc) {
CAstEntity parentType = getEnclosingType(type);
// ((JavaSourceLoaderImpl)loader).defineType(type,
@ -302,6 +322,7 @@ public class JavaCAst2IRTranslator extends AstTranslator {
return ((JavaSourceLoaderImpl) loader).defineType(type, type.getType().getName(), parentType) != null;
}
@Override
protected void leaveThis(CAstNode n, WalkContext c, CAstVisitor<WalkContext> visitor) {
if (n.getChildCount() == 0) {
super.leaveThis(n, c, visitor);
@ -312,12 +333,14 @@ public class JavaCAst2IRTranslator extends AstTranslator {
}
}
@Override
protected boolean visitCast(CAstNode n, WalkContext context, CAstVisitor<WalkContext> visitor) {
int result = context.currentScope().allocateTempValue();
context.setValue(n, result);
return false;
}
@Override
protected void leaveCast(CAstNode n, WalkContext context, CAstVisitor<WalkContext> visitor) {
int result = context.getValue(n);
CAstType toType = (CAstType) n.getChild(0).getValue();
@ -347,12 +370,14 @@ processExceptions(n, context);
}
}
@Override
protected boolean visitInstanceOf(CAstNode n, WalkContext context, CAstVisitor<WalkContext> visitor) {
int result = context.currentScope().allocateTempValue();
context.setValue(n, result);
return false;
}
@Override
protected void leaveInstanceOf(CAstNode n, WalkContext context, CAstVisitor<WalkContext> visitor) {
int result = context.getValue(n);
CAstType type = (CAstType) n.getChild(0).getValue();
@ -365,6 +390,7 @@ processExceptions(n, context);
ref));
}
@Override
protected boolean doVisit(CAstNode n, WalkContext wc, CAstVisitor<WalkContext> visitor) {
if (n.getKind() == CAstNode.MONITOR_ENTER) {
visitor.visit(n.getChild(0), wc, visitor);

View File

@ -14,6 +14,7 @@ import com.ibm.wala.cast.tree.CAstEntity;
public interface JavaProcedureEntity extends CAstEntity {
@Override
public String getSignature();
}

View File

@ -33,6 +33,7 @@ public class JavaPrimitiveTypeMap {
fShortName = shortName;
}
@Override
public String getName() {
return fShortName;
}
@ -41,6 +42,7 @@ public class JavaPrimitiveTypeMap {
return fLongName;
}
@Override
public Collection getSupertypes() {
return Collections.EMPTY_LIST;
}

View File

@ -16,5 +16,6 @@ package com.ibm.wala.cast.java.types;
import com.ibm.wala.cast.tree.CAstType;
public interface JavaType extends CAstType.Class {
@Override
boolean isInterface();
}

View File

@ -40,6 +40,7 @@ import com.ibm.wala.util.collections.Pair;
public class NuValidatorHtmlParser implements IHtmlParser {
@Override
public void parse(final URL url, final InputStream reader, final IHtmlCallback handler, final String fileName) {
URL xx = null;
try {
@ -65,18 +66,22 @@ public class NuValidatorHtmlParser implements IHtmlParser {
return r.getLineNumber();
}
@Override
public void setDocumentLocator(Locator locator) {
this.locator = locator;
}
@Override
public void startElement(String uri, final String localName, String qName, final Attributes atts) throws SAXException {
final Position line = new LineNumberPosition(url, localFileName, locator.getLineNumber());
tags.push(new ITag() {
@Override
public String getName() {
return localName;
}
@Override
public Pair<String,Position> getAttributeByName(String name) {
if (atts.getValue(name) != null) {
return Pair.make(atts.getValue(name), line);
@ -85,6 +90,7 @@ public class NuValidatorHtmlParser implements IHtmlParser {
}
}
@Override
public Map<String, Pair<String,Position>> getAllAttributes() {
return new AbstractMap<String,Pair<String,Position>>() {
private Set<Map.Entry<String,Pair<String,Position>>> es = null;
@ -97,10 +103,12 @@ public class NuValidatorHtmlParser implements IHtmlParser {
final int index = i;
es.add(new Map.Entry<String,Pair<String,Position>>() {
@Override
public String getKey() {
return atts.getLocalName(index).toLowerCase();
}
@Override
public Pair<String,Position> getValue() {
if (atts.getValue(index) != null) {
return Pair.make(atts.getValue(index), line);
@ -109,6 +117,7 @@ public class NuValidatorHtmlParser implements IHtmlParser {
}
}
@Override
public Pair<String,Position> setValue(Pair<String,Position> value) {
throw new UnsupportedOperationException();
}
@ -120,10 +129,12 @@ public class NuValidatorHtmlParser implements IHtmlParser {
};
}
@Override
public Position getElementPosition() {
return line;
}
@Override
public Position getContentPosition() {
return line;
}
@ -132,38 +143,47 @@ public class NuValidatorHtmlParser implements IHtmlParser {
handler.handleStartTag(tags.peek());
}
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
handler.handleEndTag(tags.pop());
}
@Override
public void characters(char[] ch, int start, int length) throws SAXException {
handler.handleText(new LineNumberPosition(url, localFileName, locator.getLineNumber() - countLines(ch, start, length)), new String(ch, start, length));
}
@Override
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
handler.handleText(new LineNumberPosition(url, localFileName, locator.getLineNumber()), new String(ch, start, length));
}
@Override
public void startDocument() throws SAXException {
// do nothing
}
@Override
public void endDocument() throws SAXException {
// do nothing
}
@Override
public void startPrefixMapping(String prefix, String uri) throws SAXException {
// do nothing
}
@Override
public void endPrefixMapping(String prefix) throws SAXException {
// do nothing
}
@Override
public void processingInstruction(String target, String data) throws SAXException {
// do nothing
}
@Override
public void skippedEntity(String name) throws SAXException {
// do nothing
}

View File

@ -20,6 +20,7 @@ public class TestAjaxsltCallGraphShapeRhino extends TestAjaxsltCallGraphShape {
justThisTest(TestAjaxsltCallGraphShapeRhino.class);
}
@Override
@Before
public void setUp() {
com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory());

View File

@ -17,7 +17,8 @@ import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory;
public class TestArgumentSensitivityRhino extends TestArgumentSensitivity {
@Before
@Override
@Before
public void setUp() {
JSCallGraphUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory());
}

View File

@ -22,11 +22,13 @@ import com.ibm.wala.cast.tree.impl.CAstImpl;
import com.ibm.wala.classLoader.SourceModule;
public class TestCorrelatedPairExtractionRhino extends TestCorrelatedPairExtraction {
protected CorrelationFinder makeCorrelationFinder() {
@Override
protected CorrelationFinder makeCorrelationFinder() {
return new CorrelationFinder(new CAstRhinoTranslatorFactory());
}
protected CAstEntity parseJS(CAstImpl ast, SourceModule module) throws IOException {
@Override
protected CAstEntity parseJS(CAstImpl ast, SourceModule module) throws IOException {
RhinoToAstTranslator translator = new RhinoToAstTranslator(ast, module, module.getName(), false);
CAstEntity entity = null;
try {

View File

@ -20,7 +20,8 @@ import com.ibm.wala.cast.tree.impl.CAstImpl;
import com.ibm.wala.classLoader.SourceModule;
public class TestForInBodyExtractionRhino extends TestForInBodyExtraction {
protected CAstEntity parseJS(CAstImpl ast, SourceModule module) throws IOException {
@Override
protected CAstEntity parseJS(CAstImpl ast, SourceModule module) throws IOException {
RhinoToAstTranslator translator = new RhinoToAstTranslator(ast, module, module.getName(), false);
CAstEntity entity = null;
try {

View File

@ -16,7 +16,8 @@ import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory;
public class TestForInLoopHackRhino extends TestForInLoopHack {
@Before
@Override
@Before
public void setUp() {
com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory());
}

View File

@ -21,7 +21,8 @@ public class TestJQueryExamplesRhino extends TestJQueryExamples {
justThisTest(TestJQueryExamplesRhino.class);
}
@Before
@Override
@Before
public void setUp() {
JSCallGraphUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory());
}

View File

@ -20,6 +20,7 @@ public class TestMediawikiCallGraphShapeRhino extends TestMediawikiCallGraphShap
justThisTest(TestMediawikiCallGraphShapeRhino.class);
}
@Override
@Before
public void setUp() {
com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory());

View File

@ -16,7 +16,6 @@ import static com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil.setTranslatorFa
import static com.ibm.wala.cast.js.test.JSCallGraphBuilderUtil.makeScriptScope;
import java.io.IOException;
import java.net.URL;
import java.util.Map;
import junit.framework.Assert;

View File

@ -29,6 +29,7 @@ public class TestSimpleCallGraphShapeRhino extends TestSimpleCallGraphShape {
justThisTest(TestSimpleCallGraphShapeRhino.class);
}
@Override
@Before
public void setUp() {
com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory());

View File

@ -52,13 +52,16 @@ public abstract class TestSimplePageCallGraphShapeRhino extends TestSimplePageCa
justThisTest(TestSimplePageCallGraphShapeRhino.class);
}
protected abstract IHtmlParser getParser();
@Override
protected abstract IHtmlParser getParser();
@Before
@Override
@Before
public void setUp() {
com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory());
WebUtil.setFactory(new IHtmlParserFactory() {
public IHtmlParser getParser() {
@Override
public IHtmlParser getParser() {
return TestSimplePageCallGraphShapeRhino.this.getParser();
}
});

View File

@ -3,6 +3,6 @@
<classpathentry kind="src" path="source"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="lib" path="lib/rhino-1.7R3.jar"/>
<classpathentry kind="lib" path="lib/js.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -36,4 +36,4 @@ Export-Package: com.ibm.wala.cast.js.translator,
org.mozilla.javascript.xml.impl.xmlbeans,
org.mozilla.javascript.xmlimpl
Bundle-ClassPath: .,
lib/rhino-1.7R3.jar
lib/js.jar

View File

@ -2,5 +2,5 @@ source.. = source/
output.. = bin/
bin.includes = META-INF/,\
.,\
lib/rhino-1.7R3.jar
lib/js.jar
jars.extra.classpath = lib/rhino-1.7R3.jar

View File

@ -15,7 +15,6 @@ import java.util.LinkedList;
import java.util.List;
import com.ibm.wala.cast.ir.translator.TranslatorToCAst;
import com.ibm.wala.cast.ir.translator.TranslatorToCAst.Error;
import com.ibm.wala.cast.tree.CAstEntity;
import com.ibm.wala.cast.tree.impl.CAstImpl;
import com.ibm.wala.cast.tree.rewrite.CAstRewriterFactory;
@ -34,6 +33,7 @@ public class CAstRhinoTranslator implements TranslatorToCAst {
this.replicateForDoLoops = replicateForDoLoops;
}
@Override
public <C extends RewriteContext<K>, K extends CopyKey<K>> void addRewriter(CAstRewriterFactory<C, K> factory, boolean prepend) {
if(prepend)
rewriters.add(0, factory);
@ -41,6 +41,7 @@ public class CAstRhinoTranslator implements TranslatorToCAst {
rewriters.add(factory);
}
@Override
public CAstEntity translateToCAst() throws IOException, Error {
String N;
if (M instanceof SourceFileModule) {

View File

@ -16,7 +16,8 @@ import com.ibm.wala.classLoader.SourceModule;
public class CAstRhinoTranslatorFactory implements JavaScriptTranslatorFactory {
public TranslatorToCAst make(CAst ast, SourceModule M) {
@Override
public TranslatorToCAst make(CAst ast, SourceModule M) {
return new CAstRhinoTranslator(M, false);
}
}

View File

@ -415,35 +415,43 @@ public class RhinoToAstTranslator {
return "<JS function " + getName() + ">";
}
@Override
public String getName() {
return name;
}
@Override
public String getSignature() {
Assertions.UNREACHABLE();
return null;
}
@Override
public int getKind() {
return kind;
}
@Override
public String[] getArgumentNames() {
return arguments;
}
@Override
public CAstNode[] getArgumentDefaults() {
return new CAstNode[0];
}
@Override
public int getArgumentCount() {
return arguments.length;
}
@Override
public Map<CAstNode, Collection<CAstEntity>> getAllScopedEntities() {
return Collections.unmodifiableMap(subs);
}
@Override
public Iterator<CAstEntity> getScopedEntities(CAstNode construct) {
if (subs.containsKey(construct))
return subs.get(construct).iterator();
@ -451,35 +459,43 @@ public class RhinoToAstTranslator {
return EmptyIterator.instance();
}
@Override
public CAstNode getAST() {
return ast;
}
@Override
public CAstControlFlowMap getControlFlow() {
return map;
}
@Override
public CAstSourcePositionMap getSourceMap() {
return pos;
}
@Override
public CAstSourcePositionMap.Position getPosition() {
return entityPosition;
}
@Override
public CAstNodeTypeMap getNodeTypeMap() {
return null;
}
@Override
public Collection<CAstAnnotation> getAnnotations() {
return null;
}
@Override
public Collection<CAstQualifier> getQualifiers() {
Assertions.UNREACHABLE("JuliansUnnamedCAstEntity$2.getQualifiers()");
return null;
}
@Override
public CAstType getType() {
Assertions.UNREACHABLE("JuliansUnnamedCAstEntity$2.getType()");
return null;
@ -2263,6 +2279,7 @@ private CAstNode[] walkChildren(final Node n, WalkContext context) {
class CAstErrorReporter implements ErrorReporter {
private Warning w = null;
@Override
public void error(final String arg0, final String arg1, final int arg2, final String arg3, int arg4) {
w = new Warning(Warning.SEVERE) {
@Override
@ -2272,11 +2289,13 @@ private CAstNode[] walkChildren(final Node n, WalkContext context) {
};
}
@Override
public EvaluatorException runtimeError(String arg0, String arg1, int arg2, String arg3, int arg4) {
error(arg0, arg1, arg2, arg3, arg4);
return null;
}
@Override
public void warning(String arg0, String arg1, int arg2, String arg3, int arg4) {
// ignore warnings
}

View File

@ -34,7 +34,8 @@ public class Activator extends Plugin {
* (non-Javadoc)
* @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
@ -43,7 +44,8 @@ public class Activator extends Plugin {
* (non-Javadoc)
* @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
@Override
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}

View File

@ -100,7 +100,8 @@ public class CAstDumper {
m.put(scopedEntity, e.getKey());
}
Collections.sort(scopedEntities, new Comparator<CAstEntity>() {
public int compare(CAstEntity o1, CAstEntity o2) {
@Override
public int compare(CAstEntity o1, CAstEntity o2) {
return o1.getName().compareTo(o2.getName());
}
});

View File

@ -84,6 +84,9 @@ public class JSCallGraphBuilderUtil extends com.ibm.wala.cast.js.ipa.callgraph.J
}
}
/**
* create a CG builder for script. Note that the script at dir/name is loaded via the classloader, not from the filesystem.
*/
public static JSCFABuilder makeScriptCGBuilder(String dir, String name, CGBuilderType builderType) throws IOException, WalaException {
URL script = getURLforFile(dir, name);
CAstRewriterFactory preprocessor = builderType.extractCorrelatedPairs ? new CorrelatedPairExtractorFactory(translatorFactory, script) : null;

View File

@ -89,7 +89,7 @@ public abstract class TestCorrelatedPairExtraction {
protected CAstEntity parseJS(File tmp, CAstImpl ast) throws IOException {
String moduleName = tmp.getName();
SourceFileModule module = new SourceFileModule(tmp, moduleName);
SourceFileModule module = new SourceFileModule(tmp, moduleName, null);
return parseJS(ast, module);
}

View File

@ -72,7 +72,7 @@ public abstract class TestForInBodyExtraction {
protected CAstEntity parseJS(File tmp, CAstImpl ast) throws IOException {
String moduleName = tmp.getName();
SourceFileModule module = new SourceFileModule(tmp, moduleName);
SourceFileModule module = new SourceFileModule(tmp, moduleName, null);
return parseJS(ast, module);
}

View File

@ -17,6 +17,7 @@ import com.ibm.wala.ipa.callgraph.CallGraph;
public abstract class TestJSCallGraphShape extends TestCallGraphShape {
@Override
protected Collection getNodes(CallGraph CG, String functionIdentifier) {
return JSCallGraphBuilderUtil.getNodes(CG, functionIdentifier);
}

View File

@ -32,9 +32,11 @@ public abstract class TestSimplePageCallGraphShape extends TestJSCallGraphShape
protected abstract IHtmlParser getParser();
@Override
@Before
public void setUp() {
WebUtil.setFactory(new IHtmlParserFactory() {
@Override
public IHtmlParser getParser() {
return getParser();
}

View File

@ -36,14 +36,16 @@ public class JavaScriptPlugin extends Plugin {
/**
* This method is called upon plug-in activation
*/
public void start(BundleContext context) throws Exception {
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
}
/**
* This method is called when the plug-in is stopped
*/
public void stop(BundleContext context) throws Exception {
@Override
public void stop(BundleContext context) throws Exception {
super.stop(context);
plugin = null;
resourceBundle = null;

View File

@ -37,30 +37,38 @@ public class JSTypeInference extends AstTypeInference {
super(ir, cha, new PointType(cha.lookupClass(JavaScriptTypes.Boolean)), true);
}
@Override
protected void initialize() {
class JSTypeOperatorFactory extends AstTypeOperatorFactory implements com.ibm.wala.cast.js.ssa.JSInstructionVisitor {
@Override
public void visitJavaScriptInvoke(JavaScriptInvoke inst) {
result = new DeclaredTypeOperator(new ConeType(cha.getRootClass()));
}
@Override
public void visitJavaScriptPropertyRead(JavaScriptPropertyRead inst) {
result = new DeclaredTypeOperator(new ConeType(cha.getRootClass()));
}
@Override
public void visitTypeOf(JavaScriptTypeOfInstruction inst) {
result = new DeclaredTypeOperator(new PointType(cha.lookupClass(JavaScriptTypes.String)));
}
@Override
public void visitJavaScriptInstanceOf(JavaScriptInstanceOf inst) {
result = new DeclaredTypeOperator(new PointType(cha.lookupClass(JavaScriptTypes.Boolean)));
}
@Override
public void visitJavaScriptPropertyWrite(JavaScriptPropertyWrite inst) {
}
@Override
public void visitCheckRef(JavaScriptCheckReference instruction) {
}
@Override
public void visitWithRegion(JavaScriptWithRegion instruction) {
}
@ -81,6 +89,7 @@ public class JSTypeInference extends AstTypeInference {
return new PointType(cha.lookupClass(typeRef));
}
@Override
public IVariable makeVariable(int vn) {
if (ir.getSymbolTable().isStringConstant(vn)) {
return new TypeVariable(make(JavaScriptTypes.String));
@ -100,6 +109,7 @@ public class JSTypeInference extends AstTypeInference {
init(ir, new JSTypeVarFactory(), new JSTypeOperatorFactory());
}
@Override
public TypeAbstraction getConstantType(int valueNumber) {
SymbolTable st = ir.getSymbolTable();
if (st.isStringConstant(valueNumber)) {

View File

@ -115,6 +115,7 @@ public class FlowGraph implements Iterable<Vertex> {
return graph.getSuccNodes(v);
}
@Override
public Iterator<Vertex> iterator() {
return graph.iterator();
}

View File

@ -20,35 +20,43 @@ public class AbstractVertexVisitor<T> implements VertexVisitor<T> {
return null;
}
public T visitVarVertex(VarVertex varVertex) {
@Override
public T visitVarVertex(VarVertex varVertex) {
return visitVertex(varVertex);
}
public T visitPropVertex(PropVertex propVertex) {
@Override
public T visitPropVertex(PropVertex propVertex) {
return visitVertex(propVertex);
}
public T visitUnknownVertex(UnknownVertex unknownVertex) {
@Override
public T visitUnknownVertex(UnknownVertex unknownVertex) {
return visitVertex(unknownVertex);
}
public T visitFuncVertex(FuncVertex funcVertex) {
@Override
public T visitFuncVertex(FuncVertex funcVertex) {
return visitVertex(funcVertex);
}
public T visitParamVertex(ParamVertex paramVertex) {
@Override
public T visitParamVertex(ParamVertex paramVertex) {
return visitVertex(paramVertex);
}
public T visitRetVertex(RetVertex retVertex) {
@Override
public T visitRetVertex(RetVertex retVertex) {
return visitVertex(retVertex);
}
public T visitCalleeVertex(CallVertex calleeVertex) {
@Override
public T visitCalleeVertex(CallVertex calleeVertex) {
return visitVertex(calleeVertex);
}
public T visitLexicalAccessVertex(LexicalVarVertex lexicalAccessVertex) {
@Override
public T visitLexicalAccessVertex(LexicalVarVertex lexicalAccessVertex) {
return visitVertex(lexicalAccessVertex);
}

View File

@ -37,27 +37,34 @@ public class JSInducedCFG extends AstInducedCFG {
super(r);
}
@Override
public void visitJavaScriptInvoke(JavaScriptInvoke inst) {
breakBasicBlock();
}
@Override
public void visitJavaScriptPropertyRead(JavaScriptPropertyRead inst) {
}
@Override
public void visitJavaScriptPropertyWrite(JavaScriptPropertyWrite inst) {
}
@Override
public void visitTypeOf(JavaScriptTypeOfInstruction inst) {
}
@Override
public void visitJavaScriptInstanceOf(JavaScriptInstanceOf instruction) {
}
@Override
public void visitCheckRef(JavaScriptCheckReference instruction) {
breakBasicBlock();
}
@Override
public void visitWithRegion(JavaScriptWithRegion instruction) {
}
@ -77,24 +84,31 @@ public class JSInducedCFG extends AstInducedCFG {
super(r);
}
@Override
public void visitJavaScriptInvoke(JavaScriptInvoke inst) {
}
@Override
public void visitJavaScriptPropertyRead(JavaScriptPropertyRead inst) {
}
@Override
public void visitJavaScriptPropertyWrite(JavaScriptPropertyWrite inst) {
}
@Override
public void visitTypeOf(JavaScriptTypeOfInstruction inst) {
}
@Override
public void visitJavaScriptInstanceOf(JavaScriptInstanceOf instruction) {
}
@Override
public void visitCheckRef(JavaScriptCheckReference instruction) {
}
@Override
public void visitWithRegion(JavaScriptWithRegion instruction) {
}
@ -107,10 +121,12 @@ public class JSInducedCFG extends AstInducedCFG {
}
}
@Override
protected BranchVisitor makeBranchVisitor(boolean[] r) {
return new JSBranchVisitor(r);
}
@Override
protected PEIVisitor makePEIVisitor(boolean[] r) {
return new JSPEIVisitor(r);
}

View File

@ -45,6 +45,7 @@ public class JavaScriptAnalysisEngine extends AbstractAnalysisEngine {
public JavaScriptAnalysisEngine() {
}
@Override
public void buildAnalysisScope() {
try {
loaderFactory = new JavaScriptLoaderFactory(translatorFactory);
@ -57,6 +58,7 @@ public class JavaScriptAnalysisEngine extends AbstractAnalysisEngine {
}
}
@Override
public IClassHierarchy buildClassHierarchy() {
try {
return ClassHierarchy.make(getScope(), loaderFactory, JavaScriptLoader.JS);
@ -70,14 +72,17 @@ public class JavaScriptAnalysisEngine extends AbstractAnalysisEngine {
this.translatorFactory = factory;
}
@Override
public void setJ2SELibraries(JarFile[] libs) {
Assertions.UNREACHABLE("Illegal to call setJ2SELibraries");
}
@Override
public void setJ2SELibraries(Module[] libs) {
Assertions.UNREACHABLE("Illegal to call setJ2SELibraries");
}
@Override
protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
return new JavaScriptEntryPoints(cha, cha.getLoader(JavaScriptTypes.jsLoader));
}
@ -87,6 +92,7 @@ public class JavaScriptAnalysisEngine extends AbstractAnalysisEngine {
return new AnalysisCache(AstIRFactory.makeDefaultFactory());
}
@Override
public AnalysisOptions getDefaultOptions(Iterable<Entrypoint> roots) {
final AnalysisOptions options = new AnalysisOptions(scope, roots);

View File

@ -10,7 +10,6 @@
*******************************************************************************/
package com.ibm.wala.cast.js.html;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
@ -43,11 +42,6 @@ public class CompositeFileMapping implements FileMapping {
}
@Override
public void dump(PrintStream ps) {
// TODO Auto-generated method stub
}
public String toString() {
return mappings.toString();
}

View File

@ -67,6 +67,7 @@ public class DomLessSourceExtractor extends JSSourceExtractor {
return governingTag.getElementPosition();
}
@Override
public void handleEndTag(ITag tag) {
if (tag.getName().equalsIgnoreCase("script")) {
assert currentScriptTag != null;
@ -74,6 +75,7 @@ public class DomLessSourceExtractor extends JSSourceExtractor {
}
}
@Override
public void handleText(Position p, String text) {
if (currentScriptTag != null) {
if (text.startsWith("<![CDATA[")) {
@ -93,6 +95,7 @@ public class DomLessSourceExtractor extends JSSourceExtractor {
}
}
@Override
public void handleStartTag(ITag tag) {
if (tag.getName().equalsIgnoreCase("script")) {
handleScript(tag);
@ -228,6 +231,7 @@ public class DomLessSourceExtractor extends JSSourceExtractor {
return file;
}
@Override
public void writeToFinalRegion(SourceRegion finalRegion) {
// wrapping the embedded scripts with a fake method of the window. Required for making this == window.
finalRegion.println("window.__MAIN__ = function __WINDOW_MAIN__(){");
@ -252,6 +256,7 @@ public class DomLessSourceExtractor extends JSSourceExtractor {
*/
private File tempFile;
@Override
public Set<MappedSourceModule> extractSources(URL entrypointUrl, IHtmlParser htmlParser, IUrlResolver urlResolver)
throws IOException, Error {
@ -304,7 +309,7 @@ public class DomLessSourceExtractor extends JSSourceExtractor {
Set<MappedSourceModule> res = domLessScopeGenerator.extractSources(entrypointUrl , htmlParser , urlResolver);
MappedSourceModule entry = res.iterator().next();
System.out.println(entry);
entry.getMapping().dump(System.out);
System.out.println(entry.getMapping());
}

View File

@ -10,8 +10,6 @@
*******************************************************************************/
package com.ibm.wala.cast.js.html;
import java.io.PrintStream;
import com.ibm.wala.cast.tree.CAstSourcePositionMap.Position;
public class EmptyFileMapping implements FileMapping {
@ -21,9 +19,4 @@ public class EmptyFileMapping implements FileMapping {
return null;
}
@Override
public void dump(PrintStream ps) {
ps.println("empty mapping");
}
}

View File

@ -10,8 +10,6 @@
*******************************************************************************/
package com.ibm.wala.cast.js.html;
import java.io.PrintStream;
import com.ibm.wala.cast.tree.CAstSourcePositionMap.Position;
public interface FileMapping {
@ -22,6 +20,4 @@ public interface FileMapping {
*/
public abstract IncludedPosition getIncludedPosition(Position line);
public abstract void dump(PrintStream ps);
}

View File

@ -14,10 +14,12 @@ import java.net.URL;
public class IdentityUrlResolver implements IUrlResolver{
@Override
public URL resolve(URL input) {
return input;
}
@Override
public URL deResolve(URL input) {
return input;
}

View File

@ -12,8 +12,17 @@ package com.ibm.wala.cast.js.html;
import com.ibm.wala.cast.tree.CAstSourcePositionMap.Position;
/**
* A {@link Position} for source code that has been included in some enclosing
* file, e.g., JavaScript code included in an HTML file via a script node.
*/
public interface IncludedPosition extends Position {
/**
* get the position of the containing script within the enclosing file. E.g.,
* for a position in JavaScript code included in an HTML file, returns the
* position of the relevant <code>&lt;script&gt;</code> tag in the HTML
*/
Position getIncludePosition();
}

View File

@ -12,7 +12,6 @@ package com.ibm.wala.cast.js.html;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.net.URL;
import com.ibm.wala.cast.js.html.RangeFileMapping.Range;
@ -80,11 +79,6 @@ public class NestedRangeMapping implements FileMapping {
}
@Override
public void dump(PrintStream ps) {
// TODO Auto-generated method stub
}
public String toString() {
return range + "(" + innerMapping + ")";
}

View File

@ -12,7 +12,6 @@ package com.ibm.wala.cast.js.html;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.net.URL;
import com.ibm.wala.cast.tree.CAstSourcePositionMap.Position;
@ -58,6 +57,7 @@ public class RangeFileMapping implements FileMapping {
return rangeEndingLine;
}
@Override
public String toString() {
return "{"+rangeStart+"->"+rangeEnd+"}";
}
@ -74,6 +74,7 @@ public class RangeFileMapping implements FileMapping {
includedURL = url;
}
@Override
public String toString() {
return range + ":" + includePosition;
}
@ -119,6 +120,7 @@ public class RangeFileMapping implements FileMapping {
public Position getIncludePosition() {
return includePosition;
}
@Override
public String toString() {
return "[include:"+includePosition+"]"+super.toString();
}
@ -130,10 +132,5 @@ public class RangeFileMapping implements FileMapping {
}
}
@Override
public void dump(PrintStream ps) {
// TODO Auto-generated method stub
}
}

View File

@ -15,9 +15,18 @@ import java.net.URL;
import com.ibm.wala.cast.tree.CAstSourcePositionMap.Position;
/**
* Represents a region of source code, with source locations. Regions can be
* added to other {@link SourceRegion}s, with nested source location information
* maintained.
*/
public class SourceRegion {
private final StringBuilder source = new StringBuilder();
/**
* source location information
*/
private FileMapping fileMapping;
private int currentLine = 1;

View File

@ -109,11 +109,13 @@ public class UnicodeReader extends Reader {
}
}
@Override
public void close() throws IOException {
init();
internalIn2.close();
}
@Override
public int read(char[] cbuf, int off, int len) throws IOException {
init();
return internalIn2.read(cbuf, off, len);

Some files were not shown because too many files have changed in this diff Show More