Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8175017

Do not print stack trace if initPhase2 fails

    XMLWordPrintable

    Details

      Description

      The VM calls System::initPhase2 to initialization the module system as part of create the VM. If initPhase2 fails (with an exception) then the VM aborts after printing the stack trace.

      This issue tracks changing this so that the exception (and optional cause) are printed by default without the stack trace. For diagnosability reasons then having way to print the stack trace will be needed.

      As a simple example, consider the following:

      $ java -p mods --add-modules x,y -version
      Error occurred during initialization of VM
      java.lang.RuntimeException: Package p in both module y and module x
      at jdk.internal.module.ModuleBootstrap.fail(java.base@9-internal/ModuleBootstrap.java:705)
      at jdk.internal.module.ModuleBootstrap.boot(java.base@9-internal/ModuleBootstrap.java:335)
      at java.lang.System.initPhase2(java.base@9-internal/System.java:1928)

      Another example, where the exception cause is very useful but is hard to see with the large stack trace.

      $ java -p mods -version
      Error occurred during initialization of VM
      java.lang.module.FindException: Error reading module: mods/x
      at jdk.internal.module.ModulePath.readModule(java.base@9-internal/ModulePath.java:333)
      at jdk.internal.module.ModulePath.scanDirectory(java.base@9-internal/ModulePath.java:284)
      at jdk.internal.module.ModulePath.scan(java.base@9-internal/ModulePath.java:232)
      at jdk.internal.module.ModulePath.scanNextEntry(java.base@9-internal/ModulePath.java:190)
      at jdk.internal.module.ModulePath.findAll(java.base@9-internal/ModulePath.java:166)
      at java.lang.module.ModuleFinder$2.lambda$findAll$2(java.base@9-internal/ModuleFinder.java:382)
      at java.util.stream.ReferencePipeline$7$1.accept(java.base@9-internal/ReferencePipeline.java:269)
      at java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(java.base@9-internal/AbstractList.java:720)
      at java.util.stream.AbstractPipeline.copyInto(java.base@9-internal/AbstractPipeline.java:484)
      at java.util.stream.AbstractPipeline.wrapAndCopyInto(java.base@9-internal/AbstractPipeline.java:474)
      at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(java.base@9-internal/ForEachOps.java:151)
      at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(java.base@9-internal/ForEachOps.java:174)
      at java.util.stream.AbstractPipeline.evaluate(java.base@9-internal/AbstractPipeline.java:234)
      at java.util.stream.ReferencePipeline.forEach(java.base@9-internal/ReferencePipeline.java:430)
      at java.lang.module.ModuleFinder$2.findAll(java.base@9-internal/ModuleFinder.java:383)
      at java.lang.module.Resolver.findAll(java.base@9-internal/Resolver.java:872)
      at java.lang.module.Resolver.bind(java.base@9-internal/Resolver.java:240)
      at java.lang.module.Configuration.resolveAndBind(java.base@9-internal/Configuration.java:257)
      at java.lang.module.ModuleDescriptor$1.resolveAndBind(java.base@9-internal/ModuleDescriptor.java:2792)
      at jdk.internal.module.ModuleBootstrap.boot(java.base@9-internal/ModuleBootstrap.java:284)
      at java.lang.System.initPhase2(java.base@9-internal/System.java:1928)
      Caused by: java.lang.module.InvalidModuleDescriptorException: Truncated module-info.class
      at jdk.internal.module.ModuleInfo.invalidModuleDescriptor(java.base@9-internal/ModuleInfo.java:1069)
      at jdk.internal.module.ModuleInfo.truncatedModuleDescriptor(java.base@9-internal/ModuleInfo.java:1077)
      at jdk.internal.module.ModuleInfo.read(java.base@9-internal/ModuleInfo.java:127)
      at jdk.internal.module.ModulePath.readExplodedModule(java.base@9-internal/ModulePath.java:655)
      at jdk.internal.module.ModulePath.readModule(java.base@9-internal/ModulePath.java:319)
      at jdk.internal.module.ModulePath.scanDirectory(java.base@9-internal/ModulePath.java:284)
      at jdk.internal.module.ModulePath.scan(java.base@9-internal/ModulePath.java:232)
      at jdk.internal.module.ModulePath.scanNextEntry(java.base@9-internal/ModulePath.java:190)
      at jdk.internal.module.ModulePath.findAll(java.base@9-internal/ModulePath.java:166)
      at java.lang.module.ModuleFinder$2.lambda$findAll$2(java.base@9-internal/ModuleFinder.java:382)
      at java.util.stream.ReferencePipeline$7$1.accept(java.base@9-internal/ReferencePipeline.java:269)
      at java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(java.base@9-internal/AbstractList.java:720)
      at java.util.stream.AbstractPipeline.copyInto(java.base@9-internal/AbstractPipeline.java:484)
      at java.util.stream.AbstractPipeline.wrapAndCopyInto(java.base@9-internal/AbstractPipeline.java:474)
      at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(java.base@9-internal/ForEachOps.java:151)
      at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(java.base@9-internal/ForEachOps.java:174)
      at java.util.stream.AbstractPipeline.evaluate(java.base@9-internal/AbstractPipeline.java:234)
      at java.util.stream.ReferencePipeline.forEach(java.base@9-internal/ReferencePipeline.java:430)
      at java.lang.module.ModuleFinder$2.findAll(java.base@9-internal/ModuleFinder.java:383)
      at java.lang.module.Resolver.findAll(java.base@9-internal/Resolver.java:872)
      at java.lang.module.Resolver.bind(java.base@9-internal/Resolver.java:240)
      at java.lang.module.Configuration.resolveAndBind(java.base@9-internal/Configuration.java:257)
      at java.lang.module.ModuleDescriptor$1.resolveAndBind(java.base@9-internal/ModuleDescriptor.java:2792)
      at jdk.internal.module.ModuleBootstrap.boot(java.base@9-internal/ModuleBootstrap.java:284)
      at java.lang.System.initPhase2(java.base@9-internal/System.java:1928)

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              alanb Alan Bateman
              Reporter:
              alanb Alan Bateman
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: