97 @Override 98 protected MethodHandle getGetElem() { 99 return GET_ELEM; 100 } 101 102 @Override 103 protected MethodHandle getSetElem() { 104 return SET_ELEM; 105 } 106 107 private double getElem(final int index) { 108 try { 109 return nb.get(index); 110 } catch (final IndexOutOfBoundsException e) { 111 throw new ClassCastException(); //force relink - this works for unoptimistic too 112 } 113 } 114 115 private void setElem(final int index, final double elem) { 116 try { 117 nb.put(index, (float)elem); 118 } catch (final IndexOutOfBoundsException e) { 119 //swallow valid array indexes. it's ok. 120 if (index < 0) { 121 throw new ClassCastException(); 122 } 123 } 124 } 125 126 @Override 127 public MethodHandle getElementGetter(final Class<?> returnType, final int programPoint) { 128 if (returnType == int.class || returnType == long.class) { 129 return null; 130 } 131 return getContinuousElementGetter(getClass(), GET_ELEM, returnType, programPoint); 132 } 133 134 @Override 135 public int getInt(final int index) { 136 return (int)getDouble(index); 137 } 138 139 @Override 140 public long getLong(final int index) { 141 return (long)getDouble(index); 142 } | 97 @Override 98 protected MethodHandle getGetElem() { 99 return GET_ELEM; 100 } 101 102 @Override 103 protected MethodHandle getSetElem() { 104 return SET_ELEM; 105 } 106 107 private double getElem(final int index) { 108 try { 109 return nb.get(index); 110 } catch (final IndexOutOfBoundsException e) { 111 throw new ClassCastException(); //force relink - this works for unoptimistic too 112 } 113 } 114 115 private void setElem(final int index, final double elem) { 116 try { 117 if (index < nb.limit()) { 118 nb.put(index, (float) elem); 119 } 120 } catch (final IndexOutOfBoundsException e) { 121 throw new ClassCastException(); 122 } 123 } 124 125 @Override 126 public MethodHandle getElementGetter(final Class<?> returnType, final int programPoint) { 127 if (returnType == int.class || returnType == long.class) { 128 return null; 129 } 130 return getContinuousElementGetter(getClass(), GET_ELEM, returnType, programPoint); 131 } 132 133 @Override 134 public int getInt(final int index) { 135 return (int)getDouble(index); 136 } 137 138 @Override 139 public long getLong(final int index) { 140 return (long)getDouble(index); 141 } |