RFR: 8338675: javac shouldn't silently change .jar files on the classpath [v3]
David Beaumont
duke at openjdk.org
Fri Feb 21 12:18:21 UTC 2025
On Fri, 21 Feb 2025 10:02:22 GMT, David Beaumont <duke at openjdk.org> wrote:
>> test/langtools/tools/javac/T8338675/NoOverwriteJarClassFilesByDefault.java line 66:
>>
>>> 64: * current directory may not be usable.
>>> 65: */
>>> 66: public class NoOverwriteJarClassFilesByDefault {
>>
>> Overall, I think I would mildly prefer if the test used either `TestRunner`, or junit:
>> https://github.com/openjdk/jdk/blob/master/test/langtools/tools/javac/ImportModule.java
>> https://github.com/openjdk/jdk/blob/master/test/langtools/tools/javac/util/IteratorsTest.java
>>
>> so that it is easier to add or have multiple testcases.
>
> I've seen so many different styles of test runner/setup that I'm just copying what's nearby for now. Is there a public document explaining current best practice around this?
I switched to JUnit and changed the test name to match "best practice".
>> test/langtools/tools/javac/T8338675/NoOverwriteJarClassFilesByDefault.java line 68:
>>
>>> 66: public class NoOverwriteJarClassFilesByDefault {
>>> 67:
>>> 68: private static final String OLD_LIB_SOURCE = """
>>
>> Possibly a personal preference, but I think I would put the opening `"""` on the next line, so that the text block is visibly joint.
>
> Done. Though annoying now, IntelliJ wants to format that like:
>
> private static final String OLD_LIB_SOURCE =
> """
> package lib;
> public class LibClass {
> public static final String OLD_FIELD = "This will not compile with Target";
> }
> """;
>
> which isn't great.
FYI: There's an IntelliJ Java formatter setting that fixes this ("Text Blocks" -> "Align when multiline")
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23699#discussion_r1965382280
PR Review Comment: https://git.openjdk.org/jdk/pull/23699#discussion_r1965384438
More information about the compiler-dev
mailing list