Java 5 or 6?

164 views
Skip to first unread message

Bradley Davis

unread,
Jul 16, 2010, 2:33:26 AM7/16/10
to guava-discuss
The POM in the project specifies a source and target compile of 1.5
but a number of the source files (such as ByteArrayDataInput.java)
include the Java 6 feature of allowing the @Override annotation on
direct implementations of Interface and on interfaces than extend
other interfaces. I'd file an issue, but something seems to be wrong
in the javascript on the issues page.

Kevin Bourrillion

unread,
Jul 16, 2010, 3:20:33 AM7/16/10
to guava-...@googlegroups.com
If you want to build Guava, is there a reason you can't use a newer compiler?




--
guava-...@googlegroups.com.
http://groups.google.com/group/guava-discuss?hl=en
unsubscribe: guava-discus...@googlegroups.com

This list is for discussion; for help, post to Stack Overflow instead:
http://stackoverflow.com/questions/ask
Use the tag "guava".



--
Kevin Bourrillion @ Google
http://guava-libraries.googlecode.com

Bradley Davis

unread,
Jul 16, 2010, 1:29:06 PM7/16/10
to guava-discuss
Its a maven compatibility issue. If you use the m2eclipse plugin, it
automatically sets the compiler compliance level based on the <source>
value from the POM. Java and thus Maven *used* to generate compile
errors as well, but it appears that javac 1.6.0_18 does not generate
an error for @Override on interfaces. I believe the lack of a
compiler error with -source 1.5 is actually a java compiler bug which
I've just filed bug 6969902 at the Sun issue tracker.

I actually noticed that the (guava) issue tracker says you're
targeting 1.6 now, so I attached a patch (such as it is) with the
corrected source and target values for the POM to that issue.


On Jul 16, 12:20 am, Kevin Bourrillion <kev...@google.com> wrote:
> If you want to build Guava, is there a reason you can't use a newer
> compiler?
>
> On Thu, Jul 15, 2010 at 11:33 PM, Bradley Davis <bda...@saintandreas.org>wrote:
>
>
>
>
>
> > The POM in the project specifies a source and target compile of 1.5
> > but a number of the source files (such as ByteArrayDataInput.java)
> > include the Java 6 feature of allowing the @Override annotation on
> > direct implementations of Interface and on interfaces than extend
> > other interfaces.  I'd file an issue, but something seems to be wrong
> > in the javascript on the issues page.
>
> > --
> > guava-...@googlegroups.com.
> >http://groups.google.com/group/guava-discuss?hl=en
> > unsubscribe: guava-discus...@googlegroups.com<guava-discuss%2Bunsubscribe@goog legroups.com>

Kevin Bourrillion

unread,
Jul 16, 2010, 1:40:37 PM7/16/10
to guava-...@googlegroups.com
On Fri, Jul 16, 2010 at 10:29 AM, Bradley Davis <bda...@saintandreas.org> wrote:

Its a maven compatibility issue.  If you use the m2eclipse plugin, it
automatically sets the compiler compliance level based on the <source>
value from the POM.  Java and thus Maven *used* to generate compile
errors as well, but it appears that javac 1.6.0_18 does not generate
an error for @Override on interfaces.

Nor should it.  These @Overrides, believe it or not, are 1.5-compatible.  You just need a recent 1.5 update release.  The whole situation is weird, but that's how Sun decided to handle it.

 
I actually noticed that the (guava) issue tracker says you're
targeting 1.6 now, so I attached a patch (such as it is) with the
corrected source and target values for the POM to that issue.

Whoa... where does it say that?  The last thing I said here:


... was "sadly, this probably won't happen for a long time."  It's not even on the horizon right now.  I'm really confused why you think this is a matter of just applying a patch.  It would render Guava unusable to who knows how many people.


Chris Povirk

unread,
Jul 16, 2010, 2:06:41 PM7/16/10
to guava-...@googlegroups.com
>> Its a maven compatibility issue. If you use the m2eclipse plugin, it
>> automatically sets the compiler compliance level based on the <source>
>> value from the POM. Java and thus Maven *used* to generate compile
>> errors as well, but it appears that javac 1.6.0_18 does not generate
>> an error for @Override on interfaces.
>
> Nor should it. These @Overrides, believe it or not, are 1.5-compatible.
> You just need a recent 1.5 update release. The whole situation is weird,
> but that's how Sun decided to handle it.

I've heard this before, and I'm pretty sure I confirmed that it's true
for at least some @Overrides, but I tried one of Bradley's examples
this morning with 1.5.0.22 and found that it's not universal:

$ cat OverrideInterface.java
interface SuperInterface
{
void foo();
}

interface SubInterface extends SuperInterface
{
@Override void foo();
}

$ /opt/sun-jdk-1.5.0.22/bin/javac OverrideInterface.java
OverrideInterface.java:8: method does not override a method from its superclass
@Override void foo();
^
1 error

$ /opt/sun-jdk-1.6.0.20/bin/javac OverrideInterface.java
<success>

AFAIK 1.5.0.22 is as new as it gets: "J2SE 5.0 reached its End of
Service Life (EOSL) on November 3, 2009, which is the date of the
final publicly available update of version 5.0 (J2SE 5.0 Update 22)."

Chris Povirk

unread,
Jul 16, 2010, 2:07:31 PM7/16/10
to guava-...@googlegroups.com
> $ /opt/sun-jdk-1.6.0.20/bin/javac OverrideInterface.java

(This continues to work with -source 1.5 -target 1.5.)

Bradley Davis

unread,
Jul 16, 2010, 2:53:06 PM7/16/10
to guava-discuss


On Jul 16, 10:40 am, Kevin Bourrillion <kev...@google.com> wrote:
> Nor should it.  These @Overrides, believe it or not, *are* 1.5-compatible.
>  You just need a recent 1.5 update release.  The whole situation is weird,
> but that's how Sun decided to handle it.

Whats your reference for that? I just tried it with 1.5.0_22 (linux
586 build) and it generated errors on both my test case and a fresh
checkout of Guava. I'd try it with my windows machine, but switching
JDK's on windows is much more of a PITA than on linux.

> ... was "sadly, this probably won't happen for a long time."  It's not even
> on the horizon right now.  I'm really confused why you think this is a
> matter of just applying a patch.  It would render Guava unusable to who
> knows how many people.

My mistake, I didn't fully read the comments or look at the milestone,
just the status of 'Accepted'.

Bradley Davis

unread,
Jul 16, 2010, 3:08:45 PM7/16/10
to guava-discuss
On Jul 16, 11:07 am, Chris Povirk <cpov...@google.com> wrote:
> > $ /opt/sun-jdk-1.6.0.20/bin/javac OverrideInterface.java
>
> (This continues to work with -source 1.5 -target 1.5.)

Which, until I see something official saying differently, I believe is
a bug in Java 6, not a signifier that the change has been propagated
backwards.

Kevin Bourrillion

unread,
Jul 16, 2010, 4:12:24 PM7/16/10
to guava-...@googlegroups.com
Oh no!  That wasn't supposed to happen.  I'm looking into this.  I'm seeing behavior in 5u22 that does not match what I swore I saw in 5u21 <ugh>.

It should be noted, though, that I'm still unconvinced it's a requirement for guava to be compilable in any 1.5 compiler.  There are bug fixes that I heard would never be backported.  True, we already worked around those by doing something stupid in our code, but I'd rather we wouldn't have to continue dealing with that.

Anyway, I'm digging deeper into this.


This list is for discussion; for help, post to Stack Overflow instead:
http://stackoverflow.com/questions/ask
Use the tag "guava".

Bradley Davis

unread,
Jul 16, 2010, 4:33:01 PM7/16/10
to guava-discuss
Can we reopen issue 364 for tracking? If Sun:6969902 does get
verified as a bug in 1.6 and fixed then eventually the Maven build
will break (in addition to the Eclipse/Maven integration being
somewhat broken already)

On Jul 16, 1:12 pm, Kevin Bourrillion <kev...@google.com> wrote:
> Oh no!  That wasn't supposed to happen.  I'm looking into this.  I'm seeing
> behavior in 5u22 that does not match what I swore I saw in 5u21 <ugh>.
>
> It should be noted, though, that I'm still unconvinced it's a requirement
> for guava to be compilable in any 1.5 compiler.  There are bug fixes that I
> heard would never be backported.  True, we already worked around those by
> doing something stupid in our code, but I'd rather we wouldn't have to
> continue dealing with that.
>
> Anyway, I'm digging deeper into this.
>
> On Fri, Jul 16, 2010 at 12:08 PM, Bradley Davis <bda...@saintandreas.org>wrote:
>
>
>
>
>
> > On Jul 16, 11:07 am, Chris Povirk <cpov...@google.com> wrote:
> > > > $ /opt/sun-jdk-1.6.0.20/bin/javac OverrideInterface.java
>
> > > (This continues to work with -source 1.5 -target 1.5.)
>
> > Which, until I see something official saying differently, I believe is
> > a bug in Java 6, not a signifier that the change has been propagated
> > backwards.
>
> > --
> > guava-...@googlegroups.com.
> >http://groups.google.com/group/guava-discuss?hl=en
> > unsubscribe: guava-discus...@googlegroups.com<guava-discuss%2Bunsubscribe@goog legroups.com>

Kevin Bourrillion

unread,
Jul 16, 2010, 6:02:02 PM7/16/10
to guava-...@googlegroups.com
Done.  But bugs.sun.com is telling me no such issue as that.. am I looking in the wrong place?

Bradley Davis

unread,
Jul 16, 2010, 7:15:35 PM7/16/10
to guava-discuss
A bug filed against Java doesn't show up until Sun actually reviews
it. I suspect its not going to be a high priority even though that's
just about the ONLY thing the -source 1.5 option should be checking
for. On the other hand it might be considered more urgent since any
group that has a build environment on 6 but targets 5 can no longer
use "-source 1.6 -target 1.5" to use Java 6 source code and still be
binary compatible with Java 5 (it used to work, but now emits an error
saying -target 1.5 requires -source 1.5).
Reply all
Reply to author
Forward
0 new messages