question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NPE with retrolambda

See original GitHub issue

Hi I am getting the following exception after upgrading to Kotlin v1.1:

Exception in thread "main" java.lang.NullPointerException
        at org.pitest.mutationtest.filter.KotlinFilter$1.apply(KotlinFilter.java:34)
        at org.pitest.mutationtest.filter.KotlinFilter$1.apply(KotlinFilter.java:31)
        at org.pitest.functional.predicate.Not.apply(Not.java:33)
        at org.pitest.functional.predicate.Not.apply(Not.java:23)
        at org.pitest.functional.FCollection.filter(FCollection.java:84)
        at org.pitest.functional.FCollection.filter(FCollection.java:77)
        at org.pitest.mutationtest.filter.KotlinFilter.filter(KotlinFilter.java:27)
        at org.pitest.mutationtest.filter.CompoundMutationFilter.filter(CompoundMutationFilter.java:22)
        at org.pitest.mutationtest.build.MutationSource.createMutations(MutationSource.java:52)
        at org.pitest.mutationtest.build.MutationTestBuilder$2.apply(MutationTestBuilder.java:100)
        at org.pitest.mutationtest.build.MutationTestBuilder$2.apply(MutationTestBuilder.java:97)
        at org.pitest.functional.FCollection.flatMapTo(FCollection.java:56)
        at org.pitest.functional.FCollection.flatMap(FCollection.java:66)
        at org.pitest.mutationtest.build.MutationTestBuilder.createMutationTestUnits(MutationTestBuilder.java:56)
        at org.pitest.mutationtest.tooling.MutationCoverage.buildMutationTests(MutationCoverage.java:277)
        at org.pitest.mutationtest.tooling.MutationCoverage.runReport(MutationCoverage.java:133)
        at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:103)
        at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:45)
        at org.pitest.mutationtest.commandline.MutationCoverageReport.runReport(MutationCoverageReport.java:87)
        at org.pitest.mutationtest.commandline.MutationCoverageReport.main(MutationCoverageReport.java:45)

I am running it with Gradle: ./gradlew clean pitest

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
luontolacommented, Dec 28, 2017

This has been fixed in Retrolambda 2.5.3

1reaction
szpakcommented, Apr 24, 2017

Thanks @8armed-monkey for SSCCE. It helped me to reproduce the issue.

First, I was suspecting that Kotlin is somehow leaking into the classpath use but PIT, but it’s not the case:

CP is :pitest-1.2.0.jar:/tmp/sample-npe-pitest-retrolambda/meh/build/classes/test:/tmp/sample-npe-pitest-retrolambda/meh/build/classes/main:rxjava-2.0.6.jar:junit-4.12.jar:mockito-all-1.10.19.jar:hamcrest-all-1.3.jar:reactive-streams-1.0.0.jar:hamcrest-core-1.3.jar

Later on, I realized that you mentioned that the problem occur even in projects which don’t use Kotlin (like that one 😃 ).

The NPE is in the line:

return a.getFilename().toLowerCase().endsWith(“.kt”) && a.getLineNumber() == 0;

which suggests that a filename is null. I debugged that and the ill-fated object is:

MutationDetails [id=MutationIdentifier [location=Location [clazz=test.event.EventBroadcasterImpl$$Lambda$1, method=test, methodDesc=(Ljava/lang/Object;)Z], indexes=[6], mutator=org.pitest.mutationtest.engine.gregor.mutators.ReturnValsMutator], filename=null, block=1, lineNumber=0, description=replaced return of integer sized value with (x == 0 ? 1 : 0), testsInOrder=[]]

The filename is null, but it shouldn’t. The problem may be related to retrolamba.

@8armed-monkey Could you check if the problem occurs also without retrolambda? If not, could you try to use the latest version of retrolambda (2.5.1) to verify that the problem hasn’t been already fixed? If not, it would be good to report it 😃.

@hcoles Maybe it would be good to perform a sanity check of (some) input parameters when MutationDetails is created to be able to fail fast with some more details about the context where MutationDetails was being created?

Btw, just in case, as it may not be documented (yet), to debug PIT in a Gradle build it is enough to set:

pitest {
    mainProcessJvmArgs = ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"]
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Retrolambda 3.3 in Android Studio 2.1.3: error configuring ...
Error:A problem occurred configuring project ':app'. I use Facebook and Twitter (fabric) dependencies. I removed apply plugin: 'me.tatarka.
Read more >
lambda support for Android
Put rt8.jar and retrolambda.jar into your android project directory. Modify ant.properties file inside your android project adding these lines: java.target= ...
Read more >
lombok.ast.TypeReference.rawParts java code examples | Tabnine
origin: me.tatarka.retrolambda.projectlombok/lombok.ast ... astValue(); return name.equals("void"); } catch (NullPointerException e) { return false; } }.
Read more >
Keeping up with kotlin. “java is being forced to leave android…
Java 8 has been around for a while and we are only able to use a subset of it's APIs with compilers or...
Read more >
android-retrolambda-lombok/src/main/lombok/ast/AbstractNode.java
if (position == null ) throw new NullPointerException( "position" );. this .position = position;. return this ;. } @Override public Position getPosition() {....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found