< prev index next >

src/java.base/share/classes/jdk/internal/reflect/MethodHandleIntegerFieldAccessorImpl.java

Print this page

 61 
 62     public byte getByte(Object obj) throws IllegalArgumentException {
 63         throw newGetByteIllegalArgumentException();
 64     }
 65 
 66     public char getChar(Object obj) throws IllegalArgumentException {
 67         throw newGetCharIllegalArgumentException();
 68     }
 69 
 70     public short getShort(Object obj) throws IllegalArgumentException {
 71         throw newGetShortIllegalArgumentException();
 72     }
 73 
 74     public int getInt(Object obj) throws IllegalArgumentException {
 75         try {
 76             if (isStatic()) {
 77                 return (int) getter.invokeExact();
 78             } else {
 79                 return (int) getter.invokeExact(obj);
 80             }
 81         } catch (IllegalArgumentException|NullPointerException e) {
 82             throw e;
 83         } catch (ClassCastException e) {
 84             throw newGetIllegalArgumentException(obj);
 85         } catch (Throwable e) {
 86             throw new InternalError(e);
 87         }
 88     }
 89 
 90     public long getLong(Object obj) throws IllegalArgumentException {
 91         return getInt(obj);
 92     }
 93 
 94     public float getFloat(Object obj) throws IllegalArgumentException {
 95         return getInt(obj);
 96     }
 97 
 98     public double getDouble(Object obj) throws IllegalArgumentException {
 99         return getInt(obj);
100     }
101 

148 
149     public void setShort(Object obj, short s)
150         throws IllegalArgumentException, IllegalAccessException
151     {
152         setInt(obj, s);
153     }
154 
155     public void setInt(Object obj, int i)
156         throws IllegalArgumentException, IllegalAccessException
157     {
158         if (isReadOnly()) {
159             ensureObj(obj);     // throw NPE if obj is null on instance field
160             throwFinalFieldIllegalAccessException(i);
161         }
162         try {
163             if (isStatic()) {
164                 setter.invokeExact(i);
165             } else {
166                 setter.invokeExact(obj, i);
167             }
168         } catch (IllegalArgumentException|NullPointerException e) {
169             throw e;
170         } catch (ClassCastException e) {
171             // receiver is of invalid type
172             throw newSetIllegalArgumentException(obj);
173         } catch (Throwable e) {
174             throw new InternalError(e);
175         }
176     }
177 
178     public void setLong(Object obj, long l)
179         throws IllegalArgumentException, IllegalAccessException
180     {
181         throwSetIllegalArgumentException(l);
182     }
183 
184     public void setFloat(Object obj, float f)
185         throws IllegalArgumentException, IllegalAccessException
186     {
187         throwSetIllegalArgumentException(f);
188     }

 61 
 62     public byte getByte(Object obj) throws IllegalArgumentException {
 63         throw newGetByteIllegalArgumentException();
 64     }
 65 
 66     public char getChar(Object obj) throws IllegalArgumentException {
 67         throw newGetCharIllegalArgumentException();
 68     }
 69 
 70     public short getShort(Object obj) throws IllegalArgumentException {
 71         throw newGetShortIllegalArgumentException();
 72     }
 73 
 74     public int getInt(Object obj) throws IllegalArgumentException {
 75         try {
 76             if (isStatic()) {
 77                 return (int) getter.invokeExact();
 78             } else {
 79                 return (int) getter.invokeExact(obj);
 80             }
 81         } catch (IllegalArgumentException|IllegalStateException|NullPointerException e) {
 82             throw e;
 83         } catch (ClassCastException e) {
 84             throw newGetIllegalArgumentException(obj);
 85         } catch (Throwable e) {
 86             throw new InternalError(e);
 87         }
 88     }
 89 
 90     public long getLong(Object obj) throws IllegalArgumentException {
 91         return getInt(obj);
 92     }
 93 
 94     public float getFloat(Object obj) throws IllegalArgumentException {
 95         return getInt(obj);
 96     }
 97 
 98     public double getDouble(Object obj) throws IllegalArgumentException {
 99         return getInt(obj);
100     }
101 

148 
149     public void setShort(Object obj, short s)
150         throws IllegalArgumentException, IllegalAccessException
151     {
152         setInt(obj, s);
153     }
154 
155     public void setInt(Object obj, int i)
156         throws IllegalArgumentException, IllegalAccessException
157     {
158         if (isReadOnly()) {
159             ensureObj(obj);     // throw NPE if obj is null on instance field
160             throwFinalFieldIllegalAccessException(i);
161         }
162         try {
163             if (isStatic()) {
164                 setter.invokeExact(i);
165             } else {
166                 setter.invokeExact(obj, i);
167             }
168         } catch (IllegalArgumentException|IllegalStateException|NullPointerException e) {
169             throw e;
170         } catch (ClassCastException e) {
171             // receiver is of invalid type
172             throw newSetIllegalArgumentException(obj);
173         } catch (Throwable e) {
174             throw new InternalError(e);
175         }
176     }
177 
178     public void setLong(Object obj, long l)
179         throws IllegalArgumentException, IllegalAccessException
180     {
181         throwSetIllegalArgumentException(l);
182     }
183 
184     public void setFloat(Object obj, float f)
185         throws IllegalArgumentException, IllegalAccessException
186     {
187         throwSetIllegalArgumentException(f);
188     }
< prev index next >