Skip to content

NullPointerException when instrumenting module-info.class #544

@Godin

Description

@Godin

Attempt to instrument module-info.class produced by JDK 9 EA b171 leads to

Exception in thread "main" java.io.IOException: Error while instrumenting /tmp/original/module-info.class.
	at org.jacoco.core.instr.Instrumenter.instrumentError(Instrumenter.java:165)
	at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:117)
	at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:141)
	at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:159)
	at org.jacoco.core.instr.Instrumenter.instrumentAll(Instrumenter.java:196)
	at org.jacoco.cli.internal.commands.Instrument.instrument(Instrument.java:83)
	at org.jacoco.cli.internal.commands.Instrument.instrumentRecursive(Instrument.java:72)
	at org.jacoco.cli.internal.commands.Instrument.instrumentRecursive(Instrument.java:68)
	at org.jacoco.cli.internal.commands.Instrument.execute(Instrument.java:56)
	at org.jacoco.cli.internal.Main.execute(Main.java:89)
	at org.jacoco.cli.internal.Main.main(Main.java:104)
Caused by: java.lang.NullPointerException
	at org.objectweb.asm.Item.set(Item.java:231)
	at org.objectweb.asm.ClassReader.copyPool(ClassReader.java:368)
	at org.objectweb.asm.ClassWriter.<init>(ClassWriter.java:666)
	at org.jacoco.core.instr.Instrumenter$1.<init>(Instrumenter.java:79)
	at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:79)
	at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:109)

Workaround is to exclude it from instrumentation, however there are complications:

  • in case of CLI, Maven and Ant there is no way to exclude files when instrumenting archive files (Add class includes/excludes attributes for instrumentation #187), so might require repackaging of archive files
  • in case of CLI there is no way to specify exclusions, so in addition to repackaging of archive files also requires copying of files

Metadata

Metadata

Assignees

Type

No type

Projects

Status

DONE

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions