Created attachment 765902 [details] emerge-info.txt =dev-java/stringtemplate-4.3.1 fails its test phase with a NullPointerException in one test: There was 1 failure: 1) testImportGroupAtTopLevelInJar(org.stringtemplate.v4.test.TestImports) org.junit.ComparisonFailure: expected:<[main a calls lib bold!] > but was:<[null errors: can't load group file jar:file:/var/tmp/portage/dev-java/stringtemplate-4.3.1/temp/TestImports-1645894939915/dir8386/test.jar!/main.stg Caused by: java.lang.NullPointerException at org.stringtemplate.v4.misc.STRuntimeMessage.getSourceLocation(STRuntimeMessage.java:69) at org.stringtemplate.v4.misc.STRuntimeMessage.toString(STRuntimeMessage.java:81) at Test$1.error(Test.java:16) at Test$1.runTimeError(Test.java:12) at org.stringtemplate.v4.misc.ErrorManager.runTimeError(ErrorManager.java:137) at org.stringtemplate.v4.STGroupFile.getRootDirURL(STGroupFile.java:162) at org.stringtemplate.v4.STGroup.importTemplates(STGroup.java:523) at org.stringtemplate.v4.compiler.GroupParser.group(GroupParser.java:199) at org.stringtemplate.v4.STGroup.loadGroupFile(STGroup.java:612) at org.stringtemplate.v4.STGroupFile.load(STGroupFile.java:139) at org.stringtemplate.v4.STGroupFile.load(STGroupFile.java:128) at org.stringtemplate.v4.STGroup.lookupTemplate(STGroup.java:230) at org.stringtemplate.v4.STGroup.getInstanceOf(STGroup.java:165) at Test.main(Test.java:21) ] > at org.junit.Assert.assertEquals(Assert.java:117) at org.junit.Assert.assertEquals(Assert.java:146) at org.stringtemplate.v4.test.TestImports.testImportGroupAtTopLevelInJar(TestImports.java:175) FAILURES!!! Tests run: 620, Failures: 1
Created attachment 765903 [details] dev-java:stringtemplate-4.3.1:20220226-170208.log
Note for anyone attempting to reproduce this bug: icedtea-8 was used to build the package. From build.log: GENTOO_VM=icedtea-8 CLASSPATH="" JAVA_HOME="/usr/lib64/icedtea8" JAVACFLAGS="-source 1.8 -target 1.8" COMPILER=""
I could not reproduce this bug on icedtea-8, icedtea-bin-8 or openjdk-8. However, fordfrog encountered the same test failure once before: https://github.com/gentoo/gentoo/pull/23904#issuecomment-1019916719
Sorry for spamming with multiple comments within a short time period... I successfully reproduced this with dev-java/stringtemplate-4.0.8-r1 installed on the system, after perusing attachment 765902 [details] and finding that it was reported by 'emerge --info'. Jonathan, could you please try to install =dev-java/stringtemplate-4.3.1 WITHOUT running the tests first, and see if the bug could still be reproduced after that? fordfrog, did you happen to have dev-java/stringtemplate-4.0.8-r1 installed on your system when you tested my changes in that pull request?
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=74072f9f3ff905b4683cd482fdf756cb3ea807f8 commit 74072f9f3ff905b4683cd482fdf756cb3ea807f8 Author: Yuan Liao <liaoyuan@gmail.com> AuthorDate: 2022-02-27 05:52:13 +0000 Commit: Miroslav Šulc <fordfrog@gentoo.org> CommitDate: 2022-02-27 08:11:26 +0000 dev-java/stringtemplate: Fix 4.3.1 test failure when upgrading slot 4 A test failure (as reported in the linked bug) might occur when an older version of ST 4 is already installed on the system. The failure is caused by multiple factors: the way java-pkg-simple.eclass generates the test classpath, the fact that the tests launch new JVM instances under a different working directory, and the behavior of the JVM upon an invalid path in the classpath. As of the time when this commit is created, the test classpath computed by java-pkg-simple.eclass will contain the following elements, in order: 1. The directory containing the test classes compiled by the eclass 2. The path to the JAR built by the eclass **relative to ${S}** 3. Absolute paths to dependency JARs, for both compile and test dependencies ST 4 has an implicit test dependency on itself via ANTLR 3.5 (which is yet another issue pertaining to the troublesome, malformed ANTLR 3.5 and ST 4 circular dependency). This means a version of slot 4 that is possibly older than 4.3.1 might be installed on the system and added to the test classpath within element No. 3 when the tests are being run. Some of the tests will call the 'java' command to execute ST 4 in a new JVM instance; the test classpath generated by java-pkg-simple.eclass will be reused in the classpath of the new JVM. The unfortunate factor that triggers the test failure is that the new JVM's working directory can become different from the one of the original JVM running the JUnit tests, which is ${S} when this package is being built by Portage. Note that element No. 2 in the test classpath is a relative path: after the working directory is changed, it will be invalid. However, JVM is lax in invalid path elements in the classpath: it will just ignore them and emit a "class not found" error or alike only after it has tried all other paths in the classpath to locate a class. With this behavior, JVM will pick up the copy of ST 4 already installed on the system from element No. 3 in the classpath after it detects that element No. 2 is an invalid path. Therefore, the tests will be run against ST 4 that is *installed on the system* instead of the copy that has just been built. This explains why some tests would fail when an older version of ST 4 is already installed; effectively, that old version was being tested by the test suite for the new version, and there is no guarantee that all tests would pass in this case. A corollary conclusion is that if the same version of ST 4 is being built and installed twice, and the second build has tests enabled, then the tests would pass, although effectively it would be the artifact produced by the first build being tested against. Closes: https://bugs.gentoo.org/834138 Signed-off-by: Yuan Liao <liaoyuan@gmail.com> Closes: https://github.com/gentoo/gentoo/pull/24368 Signed-off-by: Miroslav Šulc <fordfrog@gentoo.org> .../stringtemplate/stringtemplate-4.3.1.ebuild | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+)