Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6627362
Votes 0
Synopsis javac generates code that uses array.clone, which is not available on JavaCard
Category java:compiler
Reported Against
Release Fixed 7(b34), 6u10(b12) (Bug ID:2155615)
State 10-Fix Delivered, request for enhancement
Priority: 3-Medium
Related Bugs 6627364 , 6627366
Submit Date 08-NOV-2007
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;
    }
Posted Date : 2007-11-08 01:35:52.0
Work Around
N/A
Evaluation
Could make the alternate code be dependent on whether java.lang.Cloneable is on the bootclasspath.
Posted Date : 2007-11-08 01:35:52.0

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
Posted Date : 2007-11-08 23:42:34.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang