WALA icon indicating copy to clipboard operation
WALA copied to clipboard

Issue mapping method in AIC from Eclipse to WALA

Open khatchad opened this issue 8 years ago • 0 comments

I am unable to use com.ibm.wala.cast.java.translator.jdt.JDTIdentityMapper.getMethodRef(IMethodBinding) to look up a method declared in an AIC. Here's an input example that causes this error:

class A {
    void m() {
    }
    
	pubic static void main(String[] args) {
		new A() {
			@Override
			void m() {
				new ArrayList().stream().count();
			}
		};
	}
}

The input method is the m() declaration inside the AIC. Here's the client code:

MethodDeclaration mDecl = // ...
JDTIdentityMapper mapper = getJDTIdentifyMapper(mDecl);
MethodReference methodRef = mapper.getMethodRef(mDecl.resolveBinding());

And stack trace from a test I ran:

-- Error Log from JUnit --
Method: testAnonymousInnerClass
Actual: null
Expected: null
Stack Trace:
java.lang.NullPointerException
	at com.ibm.wala.cast.java.translator.jdt.JDT2CAstUtils.anonTypeName(JDT2CAstUtils.java:231)
	at com.ibm.wala.cast.java.translator.jdt.JDTIdentityMapper.anonLocalTypeToTypeID(JDTIdentityMapper.java:134)
	at com.ibm.wala.cast.java.translator.jdt.JDTIdentityMapper.typeToTypeID(JDTIdentityMapper.java:113)
	at com.ibm.wala.cast.java.translator.jdt.JDTIdentityMapper.getMethodRef(JDTIdentityMapper.java:182)

khatchad avatar Jan 16 '18 15:01 khatchad