JDK-6627362 : javac generates code that uses array.clone, which is not available on JavaCard
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2007-11-08
  • Updated: 2011-05-18
  • Resolved: 2011-05-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7 Other
6u10Fixed 7 b34Fixed OpenJDK6Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
JavaCard does not support clone() for arrays, which causes problems for enums. 
It would be nice if javac could generate different code for the values() method that does not rely on array.clone().

For example, replace the following:
    public static Color[] values() {
        return (Color[]) $VALUES.clone();
    }

with this:
    public static Color[] values() {
      Color[] copy = new Color[$VALUES.length];
      System.arraycopy($VALUES, 0, 
                       copy, 0, 
                       $VALUES.length);
      return copy;
    }

Comments
EVALUATION Per 6627366, it looks like Cloneable and Serializable have to be on the class path if a program uses Java arrays. Therefore, it is proposed to refine the test of whether or not to use clone() to - Cloneable not found - Cloneable not public
08-11-2007

EVALUATION Could make the alternate code be dependent on whether java.lang.Cloneable is on the bootclasspath.
08-11-2007