Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » problems with the OnTheFlyJavaCompiler
problems with the OnTheFlyJavaCompiler [message #883856] Sat, 09 June 2012 15:41 Go to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
Hi

I'm using the CompilationTestHelper (which relies on
OnTheFlyJavaCompiler) for testing that the generated Java code for my
DSL is Java correct; this works fine but for one case: in my DSL for
each input "entity" I generate two Java classes, say, a.A1 and a.b.A2,
where A2 "depends" on A1 (e.g., it has a field of type A1). When
CompilationTestHelper compiles A1 everything goes fine; when then it
compiles A2 the java compiler says it cannot find A1.

By debugging I found one problem:

- the classpath used by the OnTheFlyJavaCompiler does not contain the
temporary folder (where a.A1.class was compiled), and I can deal with
that with an injected custom OnTheFlyJavaCompiler which does

@Override
public String getClasspathArgs() {
final String classpathArgs = super.getClasspathArgs();
return classpathArgs
+ (classpathArgs.isEmpty() ? "" : File.pathSeparator +
createTempDir().getAbsolutePath() + File.separator);
}

this way, if I manually call the java compiler (javac) from the command
line (while the junit test is stopped in debugging mode and the java
file for A2 is in the temporary folder), everything compiles fine.

However,

- In spite of the now correct classpath, the OnTheFlyJavaCompiler still
complains that it cannot find A1, while compiling A2...

Is there any workaround?

thanks in advance
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: problems with the OnTheFlyJavaCompiler [message #884468 is a reply to message #883856] Mon, 11 June 2012 06:17 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Hi Lorenzo,

could you please file a bugzilla?

Thanks,
Sven

Am 6/9/12 5:41 PM, schrieb Lorenzo Bettini:
> Hi
>
> I'm using the CompilationTestHelper (which relies on
> OnTheFlyJavaCompiler) for testing that the generated Java code for my
> DSL is Java correct; this works fine but for one case: in my DSL for
> each input "entity" I generate two Java classes, say, a.A1 and a.b.A2,
> where A2 "depends" on A1 (e.g., it has a field of type A1). When
> CompilationTestHelper compiles A1 everything goes fine; when then it
> compiles A2 the java compiler says it cannot find A1.
>
> By debugging I found one problem:
>
> - the classpath used by the OnTheFlyJavaCompiler does not contain the
> temporary folder (where a.A1.class was compiled), and I can deal with
> that with an injected custom OnTheFlyJavaCompiler which does
>
> @Override
> public String getClasspathArgs() {
> final String classpathArgs = super.getClasspathArgs();
> return classpathArgs
> + (classpathArgs.isEmpty() ? "" : File.pathSeparator +
> createTempDir().getAbsolutePath() +
> File.separator);
> }
>
> this way, if I manually call the java compiler (javac) from the command
> line (while the junit test is stopped in debugging mode and the java
> file for A2 is in the temporary folder), everything compiles fine.
>
> However,
>
> - In spite of the now correct classpath, the OnTheFlyJavaCompiler still
> complains that it cannot find A1, while compiling A2...
>
> Is there any workaround?
>
> thanks in advance
> Lorenzo
>


--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
Re: problems with the OnTheFlyJavaCompiler [message #884528 is a reply to message #884468] Mon, 11 June 2012 09:03 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
Yes,
in the meantime a possible solution I found was to compile all the java
sources in a single command (using a custom OnTheFlyJavaCompiler); I'll
file the bug ASAP.

cheers
Lorenzo

On 06/11/2012 08:17 AM, Sven Efftinge wrote:
> Hi Lorenzo,
>
> could you please file a bugzilla?
>
> Thanks,
> Sven
>
> Am 6/9/12 5:41 PM, schrieb Lorenzo Bettini:
>> Hi
>>
>> I'm using the CompilationTestHelper (which relies on
>> OnTheFlyJavaCompiler) for testing that the generated Java code for my
>> DSL is Java correct; this works fine but for one case: in my DSL for
>> each input "entity" I generate two Java classes, say, a.A1 and a.b.A2,
>> where A2 "depends" on A1 (e.g., it has a field of type A1). When
>> CompilationTestHelper compiles A1 everything goes fine; when then it
>> compiles A2 the java compiler says it cannot find A1.
>>
>> By debugging I found one problem:
>>
>> - the classpath used by the OnTheFlyJavaCompiler does not contain the
>> temporary folder (where a.A1.class was compiled), and I can deal with
>> that with an injected custom OnTheFlyJavaCompiler which does
>>
>> @Override
>> public String getClasspathArgs() {
>> final String classpathArgs = super.getClasspathArgs();
>> return classpathArgs
>> + (classpathArgs.isEmpty() ? "" : File.pathSeparator +
>> createTempDir().getAbsolutePath() +
>> File.separator);
>> }
>>
>> this way, if I manually call the java compiler (javac) from the command
>> line (while the junit test is stopped in debugging mode and the java
>> file for A2 is in the temporary folder), everything compiles fine.
>>
>> However,
>>
>> - In spite of the now correct classpath, the OnTheFlyJavaCompiler still
>> complains that it cannot find A1, while compiling A2...
>>
>> Is there any workaround?
>>
>> thanks in advance
>> Lorenzo
>>
>
>


--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: problems with the OnTheFlyJavaCompiler [message #894969 is a reply to message #884468] Wed, 11 July 2012 09:29 Go to previous message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
https://bugs.eclipse.org/bugs/show_bug.cgi?id=384809

On 06/11/2012 08:17 AM, Sven Efftinge wrote:
> Hi Lorenzo,
>
> could you please file a bugzilla?
>
> Thanks,
> Sven
>
> Am 6/9/12 5:41 PM, schrieb Lorenzo Bettini:
>> Hi
>>
>> I'm using the CompilationTestHelper (which relies on
>> OnTheFlyJavaCompiler) for testing that the generated Java code for my
>> DSL is Java correct; this works fine but for one case: in my DSL for
>> each input "entity" I generate two Java classes, say, a.A1 and a.b.A2,
>> where A2 "depends" on A1 (e.g., it has a field of type A1). When
>> CompilationTestHelper compiles A1 everything goes fine; when then it
>> compiles A2 the java compiler says it cannot find A1.
>>
>> By debugging I found one problem:
>>
>> - the classpath used by the OnTheFlyJavaCompiler does not contain the
>> temporary folder (where a.A1.class was compiled), and I can deal with
>> that with an injected custom OnTheFlyJavaCompiler which does
>>
>> @Override
>> public String getClasspathArgs() {
>> final String classpathArgs = super.getClasspathArgs();
>> return classpathArgs
>> + (classpathArgs.isEmpty() ? "" : File.pathSeparator +
>> createTempDir().getAbsolutePath() +
>> File.separator);
>> }
>>
>> this way, if I manually call the java compiler (javac) from the command
>> line (while the junit test is stopped in debugging mode and the java
>> file for A2 is in the temporary folder), everything compiles fine.
>>
>> However,
>>
>> - In spite of the now correct classpath, the OnTheFlyJavaCompiler still
>> complains that it cannot find A1, while compiling A2...
>>
>> Is there any workaround?
>>
>> thanks in advance
>> Lorenzo
>>
>
>


--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Previous Topic:referencing java methods
Next Topic:Xcore - magic content assist for XBlockExpression
Goto Forum:
  


Current Time: Fri Apr 19 03:58:34 GMT 2024

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

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

Back to the top