Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » How to use modified javac with Eclipse and JUnit for Eclipse(is it possible?)
How to use modified javac with Eclipse and JUnit for Eclipse [message #545200] Wed, 07 July 2010 07:06 Go to next message
Nikita Lipsky is currently offline Nikita LipskyFriend
Messages: 12
Registered: July 2009
Junior Member
I have a modified javac that may produce another bytecode in compare with standard javac (and built-in to Eclipse) depending on my annotations.
I would like to use it from Eclipse.

I know that Eclipse has built in java source compiler.
However I wonder, is there any way to run my javac at least before running JUnit tests, so JUnit would use bytecode produced by my javac. I know how to do it in automated builds, but I would like to see standard Green Bar by clicking one button in Eclipse. Any suggestions would be very appreciated.

PS
Unfortunately, using AspectJ (that has Eclipse support) is not enough for my task. I think AspectJ writers should have been faced with the same problem, since they have its own compiler. If you know, how they solve the same problem, please share your knowledge Smile


Re: How to use modified javac with Eclipse and JUnit for Eclipse [message #545221 is a reply to message #545200] Wed, 07 July 2010 08:47 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Nikita Lipsky wrote:
> I have a modified javac that may produce another bytecode in compare
> with standard javac (and built-in to Eclipse) depending on my
> annotations.
> I would like to use it from Eclipse.
>
> I know that Eclipse has built in java source compiler. However I
> wonder, is there any way to run my javac at least before running
> JUnit tests, so JUnit would use bytecode produced by my javac. I know
> how to do it in automated builds, but I would like to see standard
> Green Bar by clicking one button in Eclipse. Any suggestions would be
> very appreciated.
Disable the 'Java Builder' on the 'Builders' project property page and
add use Ant instead (see 'javac' task).

Dani
>
> PS
> Unfortunately, using AspectJ (that has Eclipse support) is not enough
> for my task. I think AspectJ writers should have been faced with the
> same problem, since they have its own compiler. If you know, how they
> solve the same problem, please share your knowledge :)
>
>
>
Re: How to use modified javac with Eclipse and JUnit for Eclipse [message #545567 is a reply to message #545221] Thu, 08 July 2010 09:37 Go to previous messageGo to next message
Nikita Lipsky is currently offline Nikita LipskyFriend
Messages: 12
Registered: July 2009
Junior Member
Thank you very much for the tip.

However disabling Java builder also disables warnings in "Problems" window (they appear in source editor but not in "Problems"). Do you know any appropriate solution to overcome this?
Re: How to use modified javac with Eclipse and JUnit for Eclipse [message #545573 is a reply to message #545567] Thu, 08 July 2010 09:48 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Nikita Lipsky wrote:
> Thank you very much for the tip.
>
> However disabling Java builder also disables warnings in "Problems"
> window (they appear in source editor but not in "Problems"). Do you
> know any appropriate solution to overcome this?
Don't disable the builder and run yours afterwards.

Dani
Re: How to use modified javac with Eclipse and JUnit for Eclipse [message #545814 is a reply to message #545573] Fri, 09 July 2010 09:10 Go to previous messageGo to next message
Nikita Lipsky is currently offline Nikita LipskyFriend
Messages: 12
Registered: July 2009
Junior Member
Yes, it is possible workaround.

However, to make JUnit works, I have to configure my Ant builder to generate classfile in default output dir. Java builder also generates classfiles there and there is no way to change this, I guess. So even if my builder would run after Java builder then incremental (smart) compilation will not occur, since classfiles generated by Java builder are fresh and Ant builder decides to not recompile again.

Of course, I may configure Ant to compile all my sources always but it is not so convenient. What do you think? Are there any other handles I may turn?
Re: How to use modified javac with Eclipse and JUnit for Eclipse [message #546849 is a reply to message #545814] Wed, 14 July 2010 12:32 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Nikita Lipsky wrote:
> Yes, it is possible workaround.
> However, to make JUnit works, I have to configure my Ant builder to
> generate classfile in default output dir. Java builder also generates
> classfiles there and there is no way to change this, I guess. So even
> if my builder would run after Java builder then incremental (smart)
> compilation will not occur, since classfiles generated by Java builder
> are fresh and Ant builder decides to not recompile again.
> Of course, I may configure Ant to compile all my sources always but it
> is not so convenient. What do you think? Are there any other handles I
> may turn?
You could generate the Ant class files into a different directory and
use that one in the classpath of you JUnit launch configuration.

Dani
Re: How to use modified javac with Eclipse and JUnit for Eclipse [message #547603 is a reply to message #546849] Mon, 19 July 2010 07:01 Go to previous messageGo to next message
Nikita Lipsky is currently offline Nikita LipskyFriend
Messages: 12
Registered: July 2009
Junior Member
Dani Megert wrote on Wed, 14 July 2010 08:32
You could generate the Ant class files into a different directory and
use that one in the classpath of you JUnit launch configuration.
Dani

Yes, I have already tried this. The problem with this however, that when you launch a separate test or a subset of tests, Eclipse creates new launch configuration that does not inherit the classpath setting for the main launch configuration that makes debugging failed tests very inconvenient -- you need manually modify classpath any time you debug them.
Re: How to use modified javac with Eclipse and JUnit for Eclipse [message #547627 is a reply to message #547603] Mon, 19 July 2010 08:04 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Nikita Lipsky wrote:
> Dani Megert wrote on Wed, 14 July 2010 08:32
>> You could generate the Ant class files into a different directory and
>> use that one in the classpath of you JUnit launch configuration.
>> Dani
>
> Yes, I have already tried this. The problem with this however, that
> when you launch a separate test or a subset of tests, Eclipse creates
> new launch configuration that does not inherit the classpath setting
> for the main launch configuration that makes debugging failed tests
> very inconvenient -- you need manually modify classpath any time you
> debug them.
There's a trick which might work: you could assign your VM arguments as
default arguments to your installed JRE.

Dani
Re: How to use modified javac with Eclipse and JUnit for Eclipse [message #547667 is a reply to message #547627] Mon, 19 July 2010 10:25 Go to previous message
Nikita Lipsky is currently offline Nikita LipskyFriend
Messages: 12
Registered: July 2009
Junior Member
Dani Megert wrote on Mon, 19 July 2010 04:04
There's a trick which might work: you could assign your VM arguments as
default arguments to your installed JRE.
Dani

ok, what arguments? We need to add our Ant output to classpath of JUnit launch. If I specify "-cp" as default argument for the JRE or even "-Djava.class.path" it seems not working at all (classpath arguments that Eclipse appends later seems to override the default arguments above). If I specify -Xbootclasspath then it breaks the launch at all.

However, It seems that I have finally found a trick. If I add the Ant output folder as source folder to Build Path and configure its output to itself then it seems that Eclipse adds this output folder to the classpath of any launch. I have tried this trick and it works for the moment!
Previous Topic:How do you import a jar file into a project?
Next Topic:Configuring WLST on Eclipse
Goto Forum:
  


Current Time: Mon Jun 10 14:05:08 GMT 2024

Powered by FUDForum. Page generated in 0.66503 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top