openclover / clover

This repository contains source code of OpenClover Core as well as its integrations: Clover-for-Ant, Clover-for-Eclipse and Clover-for-IDEA plugins. Sources are licensed under Apache 2.0 license.
Other
61 stars 16 forks source link

JavaSyntax7CompilationTest fails in a non-English environment #222

Closed satob closed 11 months ago

satob commented 11 months ago

Problem

When you run mvn test on a non-English environment, the test JavaSyntax17CompilationTest.testInstrumentationAndCompilation_17_NonReifiableTypes will fail with the following error:

-------------------------------------------------------------------------------
Test set: com.atlassian.clover.JavaSyntax17CompilationTest
-------------------------------------------------------------------------------
Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 4.495 sec <<< FAILURE! - in com.atlassian.clover.JavaSyntax17CompilationTest
testInstrumentationAndCompilation_17_NonReifiableTypes(com.atlassian.clover.JavaSyntax17CompilationTest)  Time elapsed: 1.622 sec  <<< FAILURE!
junit.framework.AssertionFailedError: A pattern '.*\[unchecked\] Possible heap pollution from parameterized vararg type T.*' was not found in ant output
    at junit.framework.Assert.fail(Assert.java:57)
    at junit.framework.Assert.assertTrue(Assert.java:22)
    at junit.framework.TestCase.assertTrue(TestCase.java:192)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
    at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1484)
    at org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.callStatic(StaticMetaClassSite.java:64)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:55)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:197)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:217)
    at com.atlassian.clover.JavaSyntaxCompilationTestBase.assertAntOutputContains(JavaSyntaxCompilationTestBase.groovy:311)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
    at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:157)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:177)
    at com.atlassian.clover.JavaSyntax17CompilationTest.testInstrumentationAndCompilation_17_NonReifiableTypes(JavaSyntax17CompilationTest.groovy:49)

Solution

Setting -Duser.language=en to JAVA_TOOL_OPTIONS fixes this problem.

Note

The following workarounds didn't work for me:

  1. Add -DargLine option like mvn -DargLine="-Duser.language=en" test
  2. Add <user.language>en</user.language> to <configuration> of maven-compiler-plugin
marek-parfianowicz commented 11 months ago

I struggle reproducing it. What exact Java version do you use and what language setting do you use and where is it configured (operating system, JAVA_OPTS, ...)?

satob commented 11 months ago

I had reproduced the problem with OpenJDK 17.0.9 on Windows 11 version 22H2 (Build 22621.2428) Japanese environment.

marek-parfianowicz commented 11 months ago

Thank you! I've been testing this on MacOS trying to switch language to French/Spanish etc. Apparently, I didn't switch language correctly as my java was still printing messages in English. And what was the sample output for this failed assertion in Japanese? I'm asking because I want to know if there were still any fragments in English, I could assert on.

marek-parfianowicz commented 11 months ago

Thanks. I reproduced this. It turned out that javac has localization in Japanese but not in European languages I tried.