Eclipse missing wrong return type

M

mike

Hi,

We have the following method.

private int getOurId(Object value, Transaction c)
throws Exception {
if (value == null) {
return -1;
}
return ((MyInterface) value).getMyId(c);
}

And getMyId(c) returns an Integer object. We were expecting Eclipse to
give a compilation error, since return type is int for method, and
show the error in red within IDE. When running ant we get a
compilation error. We fixed with intValue().
The only difference we have is that we use 1.4 for ant and 1.5 in
Eclipse. Could that give such a difference?

//mike
 
L

Lew

Attribute citations.

[mike wrote:]
Daniel said:
Yes, this feature is called autoboxing and new in Java 5. See
<http://download-llnw.oracle.com/javase/1.5.0/docs/guide/language/autoboxing.html>


It lets you switch between primitives and their wrapper classes.

Given that Java 5, never mind 1.4, is already officially obsolete and nearly
six years old, it behooves us to be aware by now that version 5 brought in
significant changes, and what they are.
<http://en.wikipedia.org/wiki/Java_version_history#J2SE_5.0_.28September_30.2C_2004.29>

Any time you're dealing with different language versions, be it Java, C, BASIC
or what-have-you, it behooves you to be aware of the differences.

One of the most significant differences between Java 5 and earlier versions,
quite aside from generics and annotations and autoboxing and the rest, is the
repair to the formerly broken "memory model", that is, the rules for how data
are shared between concurrent threads.

Even though Java 6 (the current, non-obsolete version that came out
three-and-a-half years ago) introduced no significant new syntax, you still
have to remain aware of differences between it and Java 5 if you're mixing
those versions.

You can use Java 5 to build Java 1.4 projects; you just have to be sure to use
the -source, -target and -bootclasspath options correctly.

Out of curiosity, why are you stuck with such obsolete Java versions? "The
customer insists" is too shallow - what is the reasoning?
 
M

Mike Schilling

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top