src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint32Array.java

Print this page




  96         }
  97 
  98         @Override
  99         public MethodHandle getElementGetter(final Class<?> returnType, final int programPoint) {
 100             if (returnType == int.class) {
 101                 return null;
 102             }
 103             return getContinuousElementGetter(getClass(), GET_ELEM, returnType, programPoint);
 104         }
 105 
 106         private long getElem(final int index) {
 107             try {
 108                 return JSType.toUint32(nb.get(index));
 109             } catch (final IndexOutOfBoundsException e) {
 110                 throw new ClassCastException(); //force relink - this works for unoptimistic too
 111             }
 112         }
 113 
 114         private void setElem(final int index, final int elem) {
 115             try {

 116                 nb.put(index, elem);

 117             } catch (final IndexOutOfBoundsException e) {
 118                 //swallow valid array indexes. it's ok.
 119                 if (index < 0) {
 120                     throw new ClassCastException();
 121                 }
 122             }
 123         }
 124 
 125         @Override
 126         public boolean isUnsigned() {
 127             return true;
 128         }
 129 
 130         @Override
 131         public Class<?> getElementType() {
 132             return long.class;
 133         }
 134 
 135         @Override
 136         public Class<?> getBoxedElementType() {
 137             return Integer.class;
 138         }
 139 
 140         @Override
 141         public int getInt(final int index) {




  96         }
  97 
  98         @Override
  99         public MethodHandle getElementGetter(final Class<?> returnType, final int programPoint) {
 100             if (returnType == int.class) {
 101                 return null;
 102             }
 103             return getContinuousElementGetter(getClass(), GET_ELEM, returnType, programPoint);
 104         }
 105 
 106         private long getElem(final int index) {
 107             try {
 108                 return JSType.toUint32(nb.get(index));
 109             } catch (final IndexOutOfBoundsException e) {
 110                 throw new ClassCastException(); //force relink - this works for unoptimistic too
 111             }
 112         }
 113 
 114         private void setElem(final int index, final int elem) {
 115             try {
 116                 if (index < nb.limit()) {
 117                     nb.put(index, elem);
 118                 }
 119             } catch (final IndexOutOfBoundsException e) {


 120                 throw new ClassCastException();

 121             }
 122         }
 123 
 124         @Override
 125         public boolean isUnsigned() {
 126             return true;
 127         }
 128 
 129         @Override
 130         public Class<?> getElementType() {
 131             return long.class;
 132         }
 133 
 134         @Override
 135         public Class<?> getBoxedElementType() {
 136             return Integer.class;
 137         }
 138 
 139         @Override
 140         public int getInt(final int index) {