For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub
- This topic has 7 replies, 2 voices, and was last updated 20 years, 3 months ago by
Riyad Kalla.
-
AuthorPosts
-
I need to maintain a project that will run under JDK 1.3. In the project-specific settings, I set “Compiler Compliance Level” to “1.3”.
In one of my classes, I used the following statement:
BigDecimal bd = new BigDecimal(0);which is valid in 1.5, but not in 1.3 (you can’t pass an int to the BigDecimal constructor).
Should MyEclipse have caught this error? Is there something that I needed to do differently in order to have the error flagged?
Thanks,
CurtMay 10, 2006 at 2:18 pm #251875
Riyad KallaMemberCurt,
There is a confusion of two things here and it’s caused by the fact that Eclipse ships it’s own internal Java compiler. What you did when you changed your setting was actually change the bytecode that the compiler generates, BUT you left the JDK 1.5 class files in your build path. You need to navigate to your project properties and go to your Java Build Path > Libraries tab and remove the 1.5 libraries and add your 1.3 libraries. Then your project will rebuild and catch the compilation error.May 11, 2006 at 7:08 am #251916I have downloaded and installed JRE 1.3 — I have removed the JDK 1.5 libraries from the project in question. I have cleaned and rebuilt the project.
Unfortunately, it’s still not flagging the error. When I invoke code completion, I only see the valid 1.3 constructors for BigDecimal — but when I enter an integer as the argument, which is not valid in 1.3, the IDE does not flag it as a problem.
Is there something else I’m missing?
What I downloaded was the JRE, which does not have a version of javac. Does the compiler in Eclipse know to compile the project back to 1.3? If not, how do I tell it to use a different compiler?
Thanks,
CurtMay 11, 2006 at 10:06 am #251924
Riyad KallaMemberHmm, Curt you did the right steps. As long as the rt.jar file in your project is the 1.3 ones, that should be marked as an error. Double check your compiler settings for the project, they are still marked as 1.3 right?
May 11, 2006 at 12:36 pm #251938I’ve checked “Enable project specific settings”, because my Preferences tab for the IDE is still at 1.5. In the drop-down labelled “Compiler Compliance Level”, I’ve selected 1.3.
On the Build Path dialog, I double-clicked “JRE System Library [JRE 1.5]” and replaced it with “JRE System Library [JRE 1.3]” (after setting it up in the “Installed JREs” section.)
May 11, 2006 at 12:43 pm #251940
Riyad KallaMemberI think the solution is even easier than we thought… you are probably using the wrong version of 1.3, I just downloaded the most recent version of 1.3.1 from Sun, and BidDecimal does accept a constructor with an arg:
http://java.sun.com/j2se/1.3/docs/api/java/math/BigDecimal.htmlMay 11, 2006 at 2:35 pm #251944It accepts a constructor with a double or a String, but not an int.
So this line should work in 1.3:
BigDecimal bd = new BigDecimal(0D);
But this line should not:
BigDecimal bd = new BigDecimal(0);
Or at least it didn’t on my app server.
It is entirely possible that this is just a Websphere quirk. But when I ran the BigDecimal(int) statement, I received a NoSuchMethodError because Websphere couldn’t compile the method.
Curt
May 11, 2006 at 2:50 pm #251945
Riyad KallaMemberIt’s most likely a WS quirk, you can always pass in a lower value cast for a higher value. FOr example you can pass an int as a double, no problem. What you cannot do and will be marked as a compiler error (without an explicit cast) is to down convert, because precision is list.
WebSphere uses it’s own JDK, so it’s possible their compiler doesn’t like that OR that constructor was added later in the 1.3.1 revision and the version that ships with your copy of WS is an early 1.3 release that didn’t include those constructors.
-
AuthorPosts

