On Fri, 25 Oct 2024 03:06:05 GMT, Chen Liang <li...@openjdk.org> wrote:

>> test/langtools/tools/javap/8034066/EmptyLoop.jcod line 26:
>> 
>>> 24:  /*
>>> 25:  * Original source:
>>> 26:  * public class EmptyLoop {
>> 
>> To reduce test file noise, I recommend adding this as a package-private 
>> class to the end of your test file (so not a nested class) after it is 
>> renamed, like:
>> 
>> 
>> class EmptyLoop {
>>     public void emptyLoop() {
>>         for (int i = 0; i < 10; i++) {
>>         }
>>     }
>> }
>> 
>> 
>> After that, once your test class is compiled, the `EmptyLoop.class` is 
>> available in `test.classes` property directory, so you can remove this jcod 
>> and all code that converts the jcod to class.
>> 
>> You can see UndefinedAccessFlagTest for how we use such tricks.
>> 
>> Note: since you will only have one test class, you no longer need a 
>> dedicated directory; you can just place our `CodeIndentTest.java` in the 
>> root javap directory.
>
> Another example of such a trick is available at 
> [test/jdk/jdk/classfile/ClassBuildingTest.java](https://github.com/openjdk/jdk/blob/master/test/jdk/jdk/classfile/ClassBuildingTest.java)

I initially had something like this, but was not sure if the generated 
classfile could differ between jdk versions/implementations. I assume this is 
not a valid concern for such a simple example?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/21685#discussion_r1816186616

Reply via email to