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 in ClassDumper

See original GitHub issue

After adding the the linkage-checker-enforcer-rules 1.2.0 to my pom, with:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.0.0-M3</version>
                <dependencies>
                    <dependency>
                        <groupId>com.google.cloud.tools</groupId>
                        <artifactId>linkage-checker-enforcer-rules</artifactId>
                        <version>1.2.0</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>enforce-linkage-checker</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <LinkageCheckerRule implementation= "com.google.cloud.tools.dependencies.enforcer.LinkageCheckerRule">
                                    <level>WARN</level>
                                </LinkageCheckerRule>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

I encountered the following exception, immediately after the enforcer plugin gave the following warnings

[WARNING] The POM for xerces:xerces-impl:jar:2.6.2 is missing, no dependency information available
[WARNING] The POM for net.sf.ehcache:sizeof-agent:jar:1.0.1 is missing, no dependency information available
[WARNING] The POM for com.ibm.websphere:websphere_uow_api:jar:0.0.1 is missing, no dependency information available
[WARNING] The POM for com.ibm.websphere:uow:jar:6.0.2.17 is missing, no dependency information available
[WARNING] net.sf.ehcache:sizeof-agent:jar:1.0.1 was not resolved. Dependency path: com.xyz:internal-util:jar:1-SNAPSHOT > com.xyz:internal-shaded:jar:1.234 (compile) > net.sf.ehcache:ehcache-core:jar:2.6.11 (compile) > net.sf.ehcache:sizeof-agent:jar:1.0.1 (provided)
Execution enforce-linkage-checker of goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M3:enforce failed.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution enforce-linkage-checker of goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M3:enforce failed.
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.lang.NullPointerException
    at org.apache.bcel.generic.MethodGen.<init> (MethodGen.java:182)
    at com.google.cloud.tools.opensource.classpath.ClassDumper.catchesLinkageError (ClassDumper.java:500)
    at com.google.cloud.tools.opensource.classpath.ClassDumper.catchesLinkageError (ClassDumper.java:518)
    at com.google.cloud.tools.opensource.classpath.LinkageChecker.findSymbolProblem (LinkageChecker.java:482)
    at com.google.cloud.tools.opensource.classpath.LinkageChecker.lambda$findSymbolProblems$1 (LinkageChecker.java:180)
    at com.google.common.collect.ImmutableMultimap.lambda$null$2 (ImmutableMultimap.java:606)
    at java.lang.Iterable.forEach (Iterable.java:75)
    at com.google.common.collect.ImmutableMultimap.lambda$forEach$3 (ImmutableMultimap.java:606)
    at com.google.common.collect.RegularImmutableMap.forEach (RegularImmutableMap.java:185)
    at com.google.common.collect.ImmutableMultimap.forEach (ImmutableMultimap.java:605)
    at com.google.cloud.tools.opensource.classpath.LinkageChecker.findSymbolProblems (LinkageChecker.java:150)
    at com.google.cloud.tools.dependencies.enforcer.LinkageCheckerRule.execute (LinkageCheckerRule.java:203)
    at org.apache.maven.plugins.enforcer.EnforceMojo.execute (EnforceMojo.java:205)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
suztomocommented, Apr 14, 2020

Thank you for the pom.xml. I’m able to reproduce the error. Continuing investigation.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M3:enforce (enforce-linkage-checker) on project linkage-checker-error: Execution enforce-linkage-checker of goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M3:enforce failed.: NullPointerException -> [Help 1]

Memo:

javax.mail.internet.MailDateFormat is in javax:javaee-api:6.0:

Screen Shot 2020-04-14 at 10 22 13

BCEL’s MethodGen’s constructor has m.getCode().getCode(). The first m.getCode() is returning null for MailDateFormat’s constructor.

    public MethodGen(final Method m, final String class_name, final ConstantPoolGen cp) {
        this(m.getAccessFlags(), Type.getReturnType(m.getSignature()), Type.getArgumentTypes(m
                .getSignature()), null /* may be overridden anyway */
        , m.getName(), class_name,
                ((m.getAccessFlags() & (Const.ACC_ABSTRACT | Const.ACC_NATIVE)) == 0)
                        ? new InstructionList(m.getCode().getCode())
                        : null, cp);

I created a test d2975fc1c9b2598cad0fe963ea89178a7a7f5bb6 that fails due to this.

Investigating whether this is a bug in BCEL or expected NullPointerException the constructor.

There’s no byte code associated to the constructor https://gist.github.com/suztomo/97c3054b4bb320fefaaeafae4f6581af :

  public javax.mail.internet.MailDateFormat();
    descriptor: ()V
    flags: ACC_PUBLIC

Instantiating javax.mail.internet.MailDateFormat fails at runtime. Therefore BCEL’s expectation for the constructor to have the code is valid.

Screen Shot 2020-04-14 at 10 43 31

Question for BCEL is whether it’s more appropriate to throw more descriptive Exception upon such invalid class files.

Created a ticket for BCEL: BCEL-336.

0reactions
suztomocommented, Apr 15, 2020

I released com.google.cloud.tools:linkage-checker-enforcer-rules:1.2.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ordering.NumericOrdering (Luna Runtime 0.4.1 API) - javadoc.io
This class implements the Comparator interface by imposing a total order on numbers that differs from the ordering defined by the methods eq(Number,...
Read more >
NullPointerException at org.netbeans.lib.profiler.heap ...
This issue was reported manually by thurka. It already has 1 duplicates Build: NetBeans IDE 8.1 (Build 201510222201) VM: Java HotSpot(TM) ...
Read more >
SA: Running ClassDump on a simple java program generates ...
Running ClassDump on a simple java program generates NullPointerException. Lot of exceptions of the following form are generated
Read more >
Export running Java Virtual Machine - Stack Overflow
@StephaneM's solution worked sometimes, but in some cases running classdumper.jar makes Eclipse kill the process because of an ...
Read more >
Dependency Finder - Shodor
ClassDump ; ClassList; ClassMetrics; ClassReader; ClosureToText; DependablesToHTML ... 4: Class java/lang/NullPointerException 5: Field Ljava/io/PrintStream; ...
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