JDK-6983077 : given "-source 1.3" javac does not complain on Boolean.toString(boolean) as 1.4+
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: linux_ubuntu
  • CPU: x86
  • Submitted: 2010-09-08
  • Updated: 2012-03-20
  • Resolved: 2010-11-08
Related Reports
Relates :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Server VM (build 16.3-b01, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Linux lebuntu 2.6.32-24-generic #42-Ubuntu SMP Fri Aug 20 14:24:04 UTC 2010 i686 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
Given "-source 1.3" javac does not complain on Boolean.toString(boolean) as 1.4+, while it should. Expected behavior is a failure to compile.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
compile a source containing Boolean.toString(false) using javac -source 1.3

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
failure to compile
ACTUAL -
compiles fine, no warnings, no errors.

REPRODUCIBILITY :
This bug can be reproduced always.

Comments
EVALUATION As long documented in the javac manpage, to cross-compile from a newer platform version to an older one, the javac from the newer JDK must be given the rt.jar of the older JDK as the bootclasspath. Going back to the JDK 1.4.2 manpage: "[...] javac would also by default compile against its own bootstrap classes, so we need to tell javac to compile against JDK 1.1 bootstrap classes instead [to target JDK 1.1.x]. We do this with -bootclasspath and -extdirs. Failing to do this might allow compilation against a Java 2 Platform API that would not be present on a 1.1 VM and fail at runtime. " http://download.oracle.com/javase/1.4.2/docs/tooldocs/windows/javac.html Similar documention is present in the javac man pages on subsequent releases. Also see "How to cross-compile for older platform versions" http://blogs.sun.com/darcy/entry/how_to_cross_compile_for However, while this issue is being closed as not a bug, it would be helpful if javac warned if the bootclasspath was not set and an earlier source level selected, which is the subject of RFE 6900037.
08-11-2010