Organising compiled class files

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Organising compiled class files

David Holmes
I'm working on class redefinition tests which require me to have
multiple versions of the same-named class but different actual contents.
At the moment this is done via shell script that invokes javac and then
moves the generated .class files to the desired location. This seems a
bit kludgy.

Given a layout:

redefTest/RedefTest.java
redefTest/ver1/Foo.java
redeftest/ver2/Foo.java

is there a way to have jtreg compile all the source files such that the
directory structure is replicated for the .class files?

redefTest/RedefTest.d/RedefTest.class
redefTest/RedefTest.d/ver1/Foo.class
redefTest/RedefTest.d/ver2/Foo.class

Otherwise what suggestions do people have? Can ClassfileInstaller help
here? Or should I just stick with the shell script?

Thanks,
David
Reply | Threaded
Open this post in threaded view
|

Re: Organising compiled class files

Weijun Wang
Do CompilerUtils and InMemoryJavaCompiler in jdk.test.lib.compiler work for you?

--Max

> On Mar 15, 2018, at 1:09 PM, David Holmes <[hidden email]> wrote:
>
> I'm working on class redefinition tests which require me to have multiple versions of the same-named class but different actual contents. At the moment this is done via shell script that invokes javac and then moves the generated .class files to the desired location. This seems a bit kludgy.
>
> Given a layout:
>
> redefTest/RedefTest.java
> redefTest/ver1/Foo.java
> redeftest/ver2/Foo.java
>
> is there a way to have jtreg compile all the source files such that the directory structure is replicated for the .class files?
>
> redefTest/RedefTest.d/RedefTest.class
> redefTest/RedefTest.d/ver1/Foo.class
> redefTest/RedefTest.d/ver2/Foo.class
>
> Otherwise what suggestions do people have? Can ClassfileInstaller help here? Or should I just stick with the shell script?
>
> Thanks,
> David

Reply | Threaded
Open this post in threaded view
|

Re: Organising compiled class files

David Holmes
On 15/03/2018 6:41 PM, Weijun Wang wrote:
> Do CompilerUtils and InMemoryJavaCompiler in jdk.test.lib.compiler work for you?

CompilerUtils seems like it could replace the shell script. IMJC is
probably a bit too low-level (I could also exec javac).

Thanks,
David

> --Max
>
>> On Mar 15, 2018, at 1:09 PM, David Holmes <[hidden email]> wrote:
>>
>> I'm working on class redefinition tests which require me to have multiple versions of the same-named class but different actual contents. At the moment this is done via shell script that invokes javac and then moves the generated .class files to the desired location. This seems a bit kludgy.
>>
>> Given a layout:
>>
>> redefTest/RedefTest.java
>> redefTest/ver1/Foo.java
>> redeftest/ver2/Foo.java
>>
>> is there a way to have jtreg compile all the source files such that the directory structure is replicated for the .class files?
>>
>> redefTest/RedefTest.d/RedefTest.class
>> redefTest/RedefTest.d/ver1/Foo.class
>> redefTest/RedefTest.d/ver2/Foo.class
>>
>> Otherwise what suggestions do people have? Can ClassfileInstaller help here? Or should I just stick with the shell script?
>>
>> Thanks,
>> David
>
Reply | Threaded
Open this post in threaded view
|

Re: Organising compiled class files

Jonathan Gibbons
Agreed that using code to drive javac is the way to go.  I'd recommend
trying to call javac via API if possible, just to save the startup cost
of execing javac.

As well as the CompilerUtils test library, you can also use the new-in-9
java.util.spi.ToolProvider to get the "javac" provider, that provides
the facilities as command-line use of javac, albeit in the same JVM.

-- Jon


On 3/15/18 2:43 AM, David Holmes wrote:

> On 15/03/2018 6:41 PM, Weijun Wang wrote:
>> Do CompilerUtils and InMemoryJavaCompiler in jdk.test.lib.compiler
>> work for you?
>
> CompilerUtils seems like it could replace the shell script. IMJC is
> probably a bit too low-level (I could also exec javac).
>
> Thanks,
> David
>
>> --Max
>>
>>> On Mar 15, 2018, at 1:09 PM, David Holmes <[hidden email]>
>>> wrote:
>>>
>>> I'm working on class redefinition tests which require me to have
>>> multiple versions of the same-named class but different actual
>>> contents. At the moment this is done via shell script that invokes
>>> javac and then moves the generated .class files to the desired
>>> location. This seems a bit kludgy.
>>>
>>> Given a layout:
>>>
>>> redefTest/RedefTest.java
>>> redefTest/ver1/Foo.java
>>> redeftest/ver2/Foo.java
>>>
>>> is there a way to have jtreg compile all the source files such that
>>> the directory structure is replicated for the .class files?
>>>
>>> redefTest/RedefTest.d/RedefTest.class
>>> redefTest/RedefTest.d/ver1/Foo.class
>>> redefTest/RedefTest.d/ver2/Foo.class
>>>
>>> Otherwise what suggestions do people have? Can ClassfileInstaller
>>> help here? Or should I just stick with the shell script?
>>>
>>> Thanks,
>>> David
>>