Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Not Using the Internal Compiler(Not Using the Internal Compiler)
Not Using the Internal Compiler [message #811880] Fri, 02 March 2012 23:35 Go to next message
Tim Smith is currently offline Tim SmithFriend
Messages: 1
Registered: March 2012
Junior Member
I've seen some old answers to this question but not sure if it may have changed in the latest releases. Is there a way to use an external JDK to compile code (without ant scripts) in eclipse, or does eclipse always use the built in ejc to compile code and show warnings (red underlines, gutter messages)? Thanks
Re: Not Using the Internal Compiler [message #811940 is a reply to message #811880] Sat, 03 March 2012 01:42 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1351
Registered: July 2009
Senior Member
On 03/02/2012 05:35 PM, Tim Smith wrote:
> I've seen some old answers to this question but not sure if it may have
> changed in the latest releases. Is there a way to use an external JDK to
> compile code (without ant scripts) in eclipse, or does eclipse always
> use the built in ejc to compile code and show warnings (red underlines,
> gutter messages)? Thanks
It always uses the ejc compiler.
Re: Not Using the Internal Compiler [message #901280 is a reply to message #811880] Fri, 10 August 2012 15:31 Go to previous messageGo to next message
Peter Wilhelm Gstettner is currently offline Peter Wilhelm GstettnerFriend
Messages: 1
Registered: May 2012
Junior Member
First, I do not know, if this is the right place for this, but google brought me here, so I might as well give it a try Wink

In fact, using it's own compiler causes some trouble in the real world. This is because the compiler that comes with eclipse seems to be a lot more capable than the one shipped with your (or my) JDK.

Especially when generics are used, there seem to be some major shortcomings in current javac implementations (at least for jdk 1.6_x).
So someone can write some amount of code until he or she recognizes that something will not work/compile in the to be shipped product (because ant/maven/gradle will fail to build it using javac).

e.g I got something like the following, which compiles fine in eclipse but fails to compile with javac:

package weird;

public class DoesNotCompile {

   class A<X extends A<X>> {
      class B<Y extends A<X>> {
      }
   }

   class C extends A<C> {
      public C() {
         B<C> b = new B<C>();
         System.out.println("b: " + b.toString());
      }
   }
}



vs. javac:

formerly-black-sheep:src peter$ javac weird/DoesNotCompile.java 
weird/DoesNotCompile.java:12: type parameter weird.DoesNotCompile.C is not within its bound
         B<C> b = new B<C>();
           ^



NOTE: it will not make any difference if the outer class (DoesNotCompile) is left and the classes A and C are put in separate files. Just put them in one file for convenience...
Re: Not Using the Internal Compiler [message #901563 is a reply to message #901280] Mon, 13 August 2012 12:18 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3801
Registered: July 2009
Senior Member
On 10.08.2012 17:31, Peter Wilhelm Gstettner wrote:
> First, I do not know, if this is the right place for this, but google
> brought me here, so I might as well give it a try ;)
>
> In fact, using it's own compiler causes some trouble in the real
> world. This is because the compiler that comes with eclipse seems to
> be a lot more capable than the one shipped with your (or my) JDK.
>
> Especially when generics are used, there seem to be some major
> shortcomings in current javac implementations (at least for jdk 1.6_x).
> So someone can write some amount of code until he or she recognizes
> that something will not work/compile in the to be shipped product
> (because ant/maven/gradle will fail to build it using javac).
The same is true if you just stay with javac only: newer versions have
this bug fixed (even if you set the source and target to 1.6) and if you
then switch to another/older version, it won't compile.

Dani
>
> e.g I got something like the following, which compiles fine in eclipse
> but fails to compile with javac:
>
>
> package weird;
>
> public class DoesNotCompile {
>
> class A<X extends A<X>> {
> class B<Y extends A<X>> {
> }
> }
>
> class C extends A<C> {
> public C() {
> B<C> b = new B<C>();
> System.out.println("b: " + b.toString());
> }
> }
> }
>
>
>
> vs. javac:
>
>
> formerly-black-sheep:src peter$ javac weird/DoesNotCompile.java
> weird/DoesNotCompile.java:12: type parameter weird.DoesNotCompile.C is
> not within its bound
> B<C> b = new B<C>();
> ^
>
>
>
> NOTE: it will not make any difference if the outer class
> (DoesNotCompile) is left and the classes A and C are put in separate
> files. Just put them in one file for convenience...
Re: Not Using the Internal Compiler [message #901653 is a reply to message #901563] Mon, 13 August 2012 21:48 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1048
Registered: July 2009
Senior Member
Depending on your build tool there should be ways of avoiding this confusion by always using ecj.

For ant see http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftask-ant_javac_adapter.htm

For maven see http://wiki.eclipse.org/Tycho/FAQ#Can_I_use_the_Tycho_compiler_support_in_non-OSGi_projects.2C_too.3F

HTH,
Stephan
Previous Topic:Possible preference change?
Next Topic:Eclipse plugin for GUI design with JQuery UI Components
Goto Forum:
  


Current Time: Sat Dec 20 00:12:12 GMT 2014

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

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