Skip to main content

Allow javac to disable autoboxing!

6 replies [Last post]
keeskuip
Offline
Joined: 2003-06-17

I really like jdk1.5. But one thing that should have NEVER been allowed is autoboxing. It is doing things I do not want it to do, I do not want javac to do self-casting/converting, I just want to correct the error i made.

So I would like to have the option of disabling autoboxing with javac.

Kees

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
peterahe
Offline
Joined: 2004-11-22

> So I would like to have the option of disabling
> autoboxing with javac.

The Java programming language is a package deal.
It is specified by the JLS and conforming compilers
are not allowed to pick and choose between features.

The only exception is the -source option which
allows you to specify an older language version.

tsinger
Offline
Joined: 2003-06-10

> But one thing that should have
> NEVER been allowed is autoboxing.

If you mean auto[b]un[/b]boxing, I whole-heartly agree. At least there must be a compiler option to not allow this (to prevent the newly introduced NPE-source).

Tom

subanark
Offline
Joined: 2004-11-26

I agree with keeskuip, disagree with tsinger.

Compiler options on the command line should be very limited, e.g. what happens when one programmer uses auto-boxing, and another one doesn't use it.

Even though it would complicate the java language, having an annotation to disable auto boxing would allow both pieces of code to live and compile together.

jwenting
Offline
Joined: 2003-12-02

You already have an option to disable it, which is to use the -source 1.4 argument on the commandline.

As said you either take the entire language spec or none of it. If you don't like it, use another language.

I don't like annotations, and won't use them. But I'm not clamoring for a compiler option to disallow them (I'd not shed any tears if they were removed altogether though, but that's another scenario).

tsinger
Offline
Joined: 2003-06-10

The problem with this particular autounboxing feature is, that one _accidently_ can use it, even when you don't want to do that, just because the compiler compiles your application fine. Compared to Java 1.4, this is a new NPE source.

Regarding annotations, I don't need them, too, but these I can avoid without problems. Just to make it clear again: avoiding autounboxing and keeping other 1.5-goodies is quite impossible. I know, there are options in decent IDEs to mark autounboxing as warning/error in the editor, but nevertheless, it compiles fine.

IMHO opinion, the autounboxing should have been left out of any Java version - like other just-type-safing requests coming up all the time in these forum.

jwenting
Offline
Joined: 2003-12-02

I agree that maybe it shouldn't have been put in in the first place, but the suggestion of adding a compiler flag to disable it means a cure worse than the disease.