On Tue, Nov 23, 2010 at 2:35 AM, Tom Hawtin <[email protected]> wrote: > On Nov 22, 4:53 pm, Craig Kelley <[email protected]> wrote: > >> We have an application targeting jre6 that is getting null pointer >> exceptions from variables supposedly declared final, referenced from >> inner classes. > > I am guess the difference is in the javac compilation, and which JRE > version you are targeting. `javap -c` is your friend. > > From memory, javac in jdk1.4 defaulted to generating code for earlier > releases. jdk5 and 6 uses the current version.
Correct; more details on how javac -source and -target options relate to class files versions is written up at: "Source, target, class file version decoder ring" http://blogs.sun.com/darcy/entry/source_target_class_file_version > The important thing is > that we are comparing pre-1.4 code with post-1.4 code. If you use code > compiled with 1.4 on 6, you should see the 1.4 behaviour. It used to > be if you used -source 1.3 -target 1.3 on jdk6 you would see the 1.4 > results, but I think that may have been dropped quietly at some point. It is not guaranteed that "newjavac -source old -target old ..." will produce the same outout as "oldjavac ..." since, besides bug fixes, various changes can be made in compiler-internal contracts, such as code generation idioms. For example, one compiler-internal contract that has evolved over time is the idiom used to access private members of an enclosing class. -Joe -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
