JDK-6627362 : javac generates code that uses array.clone, which is not available on JavaCard
  • Type: Enhancement
  • Status: Closed
  • Resolution: Fixed
  • Component: tools
  • Sub-Component: javac
  • Priority: P3
  • Affected Version: 7
  • OS: generic
  • CPU: generic
  • Submit Date: 2007-11-08
  • Updated Date: 2011-05-18
  • Resolved Date: 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 Availabitlity Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u10Resolved 7 b34Fixed
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
2007-11-08

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