JDK-8242282 : Test sun/tools/jps/TestJps.java fails after JDK-8237572
  • Type: Bug
  • Component: core-svc
  • Sub-Component: tools
  • Affected Version: 15
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-04-07
  • Updated: 2020-04-16
  • Resolved: 2020-04-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 15
15 b19Fixed
Related Reports
Relates :  
Description
 LingeredApp stderr: [Error: Could not find or load main class LingeredAppForJps
Caused by: java.lang.NoClassDefFoundError: jdk/test/lib/apps/LingeredApp
java.lang.NoClassDefFoundError: jdk/test/lib/apps/LingeredApp
	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1014)
	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
	at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:825)
	at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:723)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:646)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:604)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:431)
	at java.base/sun.launcher.LauncherHelper.loadMainClass(LauncherHelper.java:780)
	at java.base/sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:675)
Caused by: java.lang.ClassNotFoundException: jdk.test.lib.apps.LingeredApp
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
	... 13 more
]
Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/34b6292f47df User: amenkov Date: 2020-04-10 17:52:44 +0000
10-04-2020

I developed prototypes for all 3 ways, looks like all of them work I prefer solution #3 (and explicitly add @build tag for lib classes) as it looks more clear and less error-prone solution
09-04-2020

Mainly it's about modifying sources between runs. As we cannot clean classes from lib directories, we can't be sure we have all required files in the test directory. I don't like that we have different behavior in different runs (this is what this bug about) - sometimes lib classes are compiled into test dir, sometimes not. Also found the following (from https://openjdk.java.net/jtreg/tag-spec.html): =================== In general, classes in library directories are not automatically compiled as part of a compilation command explicitly naming the source files containing those classes. A test that relies upon library classes should contain appropriate @build directives to ensure that the classes will be compiled. It is strongly recommended that tests do not rely on the use of implicit compilation by the Java compiler. Such an approach is generally fragile, and may lead to incomplete recompilation when a test or library code has been modified. ===================
09-04-2020

For (2) why are incremental test runs a concern? Is it only a concern if you are modifying the test or related classes between runs?
09-04-2020

The test creates jar file including files only from test directory (and this looks good as classpath can contains other directories). The root cause of the failures is some classes required for LingeredAppForJps are located in jdk/test/lib which are compiled to different directory (I don't quite understand how JTReg compiles classes to sometimes jdk/test/lib .classes appears in the test class directories). To solve the problem we have 3 ways: 1. add to jar file files from all classpath directories. This doesn't look good as we can include a lot of non-required stuff; 2. force jtreg to compile lib classes to test directory (adding @build LingeredAppForJps) so required files from lib dir are compiled into test directory. This works fine from scratch, but can cause issues with incremental test runs and jtreg does not allow to clean class files from library directories, only from the test directory; 3. modify manifest for generated jar file adding lib directories to the jar classpath.
09-04-2020

This failure is showing in up varying numbers in every Tier5 CI job set. Please ProblemList this test if a solution is not coming soon.
08-04-2020

I've seen something like this before, but it's been years and I can't recall the root cause. I wonder if there is some conflict with TestJpsSanity.java. They both run around the same time. It might be that TestJpsSanity has triggered compilation of some of the classes that are needed, but it's not done yet when TestJps starts to run and then just jars up whatever is present. However, they seem to have their own classes directories, so I don't see how this could happen.
08-04-2020

It looks like timing/caching issue The test creates jar file to run LingeredAppForJps For successful run it contains: 0 Tue Apr 07 14:57:02 PDT 2020 META-INF/ 102 Tue Apr 07 14:57:02 PDT 2020 META-INF/MANIFEST.MF 0 Tue Apr 07 14:56:20 PDT 2020 jdk/ 0 Tue Apr 07 14:56:20 PDT 2020 jdk/test/ 0 Tue Apr 07 14:56:28 PDT 2020 jdk/test/lib/ 0 Tue Apr 07 14:56:20 PDT 2020 jdk/test/lib/apps/ 10333 Tue Apr 07 14:56:20 PDT 2020 jdk/test/lib/apps/LingeredApp.class 6763 Tue Apr 07 14:56:20 PDT 2020 jdk/test/lib/Asserts.class 2453 Tue Apr 07 14:56:24 PDT 2020 jdk/test/lib/JDKToolFinder.class 2017 Tue Apr 07 14:56:28 PDT 2020 jdk/test/lib/JDKToolLauncher.class 11070 Tue Apr 07 14:56:28 PDT 2020 jdk/test/lib/NetworkConfiguration.class 8969 Tue Apr 07 14:56:26 PDT 2020 jdk/test/lib/Platform.class 0 Tue Apr 07 14:56:24 PDT 2020 jdk/test/lib/process/ 11039 Tue Apr 07 14:56:22 PDT 2020 jdk/test/lib/process/OutputAnalyzer.class 728 Tue Apr 07 14:56:20 PDT 2020 jdk/test/lib/process/OutputBuffer$EagerOutputBuffer.class 1732 Tue Apr 07 14:56:20 PDT 2020 jdk/test/lib/process/OutputBuffer$LazyOutputBuffer$StreamTask.class 2568 Tue Apr 07 14:56:20 PDT 2020 jdk/test/lib/process/OutputBuffer$LazyOutputBuffer.class 454 Tue Apr 07 14:56:20 PDT 2020 jdk/test/lib/process/OutputBuffer$OutputBufferException.class 1270 Tue Apr 07 14:56:20 PDT 2020 jdk/test/lib/process/OutputBuffer.class 877 Tue Apr 07 14:56:24 PDT 2020 jdk/test/lib/process/ProcessTools$1.class 1132 Tue Apr 07 14:56:24 PDT 2020 jdk/test/lib/process/ProcessTools$2.class 1173 Tue Apr 07 14:56:24 PDT 2020 jdk/test/lib/process/ProcessTools$LineForwarder.class 2024 Tue Apr 07 14:56:24 PDT 2020 jdk/test/lib/process/ProcessTools$ProcessImpl.class 12852 Tue Apr 07 14:56:24 PDT 2020 jdk/test/lib/process/ProcessTools.class 590 Tue Apr 07 14:56:22 PDT 2020 jdk/test/lib/process/StreamPumper$LinePump.class 380 Tue Apr 07 14:56:22 PDT 2020 jdk/test/lib/process/StreamPumper$Pump.class 590 Tue Apr 07 14:56:22 PDT 2020 jdk/test/lib/process/StreamPumper$StreamPump.class 5029 Tue Apr 07 14:56:22 PDT 2020 jdk/test/lib/process/StreamPumper.class 282 Tue Apr 07 14:56:22 PDT 2020 jdk/test/lib/Utils$ThrowingRunnable.class 20912 Tue Apr 07 14:56:22 PDT 2020 jdk/test/lib/Utils.class 732 Tue Apr 07 14:56:28 PDT 2020 JpsHelper$1.class 2730 Tue Apr 07 14:56:28 PDT 2020 JpsHelper$JpsArg.class 6745 Tue Apr 07 14:56:28 PDT 2020 JpsHelper.class 4158 Tue Apr 07 14:56:26 PDT 2020 LingeredAppForJps.class 1123 Tue Apr 07 14:56:18 PDT 2020 TestJps.class For failures it contains only part of files: 0 Tue Apr 07 11:11:08 GMT 2020 META-INF/ 96 Tue Apr 07 11:11:08 GMT 2020 META-INF/MANIFEST.MF 732 Tue Apr 07 11:06:28 GMT 2020 JpsHelper$1.class 2730 Tue Apr 07 11:06:28 GMT 2020 JpsHelper$JpsArg.class 6745 Tue Apr 07 11:06:28 GMT 2020 JpsHelper.class 3845 Tue Apr 07 11:06:28 GMT 2020 LingeredAppForJps.class 1123 Tue Apr 07 11:06:28 GMT 2020 TestJps.class or 0 Tue Apr 07 11:44:28 GMT 2020 META-INF/ 96 Tue Apr 07 11:44:28 GMT 2020 META-INF/MANIFEST.MF 0 Tue Apr 07 11:39:56 GMT 2020 jdk/ 0 Tue Apr 07 11:39:56 GMT 2020 jdk/test/ 0 Tue Apr 07 11:39:56 GMT 2020 jdk/test/lib/ 6763 Tue Apr 07 11:39:56 GMT 2020 jdk/test/lib/Asserts.class 732 Tue Apr 07 11:39:56 GMT 2020 JpsHelper$1.class 2730 Tue Apr 07 11:39:56 GMT 2020 JpsHelper$JpsArg.class 6745 Tue Apr 07 11:39:56 GMT 2020 JpsHelper.class 3845 Tue Apr 07 11:39:56 GMT 2020 LingeredAppForJps.class 1123 Tue Apr 07 11:39:56 GMT 2020 TestJps.class
07-04-2020