Skip to content

[Bug]: TypeResolver AssertionError for String methods expecting CharSequence invoked via String literal #975

@stschott

Description

@stschott

What happened?

Since v1.3.0 the TypeResolver throws an AssertionError, when trying to call getBody() on a method like this:

public void method() {
        String someString = "Some String";
        boolean a = someString.contains("abc");
}

The contains method expects a CharSequence as parameter.

Further investigation showed that this only happens for methods expecting a CharSequence parameter, when directly invoked with a String literal.

Version

Latest develop branch

Relevant log output

java.lang.AssertionError
	at sootup.java.core.interceptors.typeresolving.TypePromotionVisitor.visit(TypePromotionVisitor.java:68)
	at sootup.java.core.interceptors.typeresolving.TypeChecker.handleInvokeExpr(TypeChecker.java:300)
	at sootup.java.core.interceptors.typeresolving.TypeChecker.caseAssignStmt(TypeChecker.java:220)
	at sootup.core.jimple.common.stmt.JAssignStmt.accept(JAssignStmt.java:201)
	at sootup.core.jimple.common.stmt.JAssignStmt.accept(JAssignStmt.java:59)
	at sootup.java.core.interceptors.typeresolving.TypePromotionVisitor.getPromotedTyping(TypePromotionVisitor.java:47)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566)
	at sootup.java.core.interceptors.typeresolving.TypeResolver.resolve(TypeResolver.java:81)
	at sootup.java.core.interceptors.TypeAssigner.interceptBody(TypeAssigner.java:42)
	at sootup.java.bytecode.frontend.AsmMethodSource.resolveBody(AsmMethodSource.java:234)
	at sootup.core.model.SootMethod.lazyBodyInitializer(SootMethod.java:98)
	at com.google.common.base.Suppliers$NonSerializableMemoizingSupplier.get(Suppliers.java:181)
	at sootup.core.model.SootMethod.getBody(SootMethod.java:177)
	at java.lang.Iterable.forEach(Iterable.java:75)
	at sootup.java.bytecode.SpecialCharacterMethodInvocationTest.test(SpecialCharacterMethodInvocationTest.java:24)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at java.util.ArrayList.forEach(ArrayList.java:1259)
	at java.util.ArrayList.forEach(ArrayList.java:1259)

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions