< prev index next >

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

Print this page

 69 
 70     public short getShort(Object obj) throws IllegalArgumentException {
 71         throw newGetShortIllegalArgumentException();
 72     }
 73 
 74     public int getInt(Object obj) throws IllegalArgumentException {
 75         throw newGetIntIllegalArgumentException();
 76     }
 77 
 78     public long getLong(Object obj) throws IllegalArgumentException {
 79         throw newGetLongIllegalArgumentException();
 80     }
 81 
 82     public float getFloat(Object obj) throws IllegalArgumentException {
 83         try {
 84             if (isStatic()) {
 85                 return (float) getter.invokeExact();
 86             } else {
 87                 return (float) getter.invokeExact(obj);
 88             }
 89         } catch (IllegalArgumentException|NullPointerException e) {
 90             throw e;
 91         } catch (ClassCastException e) {
 92             throw newGetIllegalArgumentException(obj);
 93         } catch (Throwable e) {
 94             throw new InternalError(e);
 95         }
 96     }
 97 
 98     public double getDouble(Object obj) throws IllegalArgumentException {
 99         return getFloat(obj);
100     }
101 
102     public void set(Object obj, Object value)
103             throws IllegalArgumentException, IllegalAccessException
104     {
105         ensureObj(obj);
106         if (isReadOnly()) {
107             throwFinalFieldIllegalAccessException(value);
108         }
109 

166 
167     public void setLong(Object obj, long l)
168         throws IllegalArgumentException, IllegalAccessException
169     {
170         setFloat(obj, l);
171     }
172 
173     public void setFloat(Object obj, float f)
174         throws IllegalArgumentException, IllegalAccessException
175     {
176         if (isReadOnly()) {
177             ensureObj(obj);     // throw NPE if obj is null on instance field
178             throwFinalFieldIllegalAccessException(f);
179         }
180         try {
181             if (isStatic()) {
182                 setter.invokeExact(f);
183             } else {
184                 setter.invokeExact(obj, f);
185             }
186         } catch (IllegalArgumentException|NullPointerException e) {
187             throw e;
188         } catch (ClassCastException e) {
189             // receiver is of invalid type
190             throw newSetIllegalArgumentException(obj);
191         } catch (Throwable e) {
192             throw new InternalError(e);
193         }
194     }
195 
196     public void setDouble(Object obj, double d)
197         throws IllegalArgumentException, IllegalAccessException
198     {
199         throwSetIllegalArgumentException(d);
200     }
201 }

 69 
 70     public short getShort(Object obj) throws IllegalArgumentException {
 71         throw newGetShortIllegalArgumentException();
 72     }
 73 
 74     public int getInt(Object obj) throws IllegalArgumentException {
 75         throw newGetIntIllegalArgumentException();
 76     }
 77 
 78     public long getLong(Object obj) throws IllegalArgumentException {
 79         throw newGetLongIllegalArgumentException();
 80     }
 81 
 82     public float getFloat(Object obj) throws IllegalArgumentException {
 83         try {
 84             if (isStatic()) {
 85                 return (float) getter.invokeExact();
 86             } else {
 87                 return (float) getter.invokeExact(obj);
 88             }
 89         } catch (IllegalArgumentException|IllegalStateException|NullPointerException e) {
 90             throw e;
 91         } catch (ClassCastException e) {
 92             throw newGetIllegalArgumentException(obj);
 93         } catch (Throwable e) {
 94             throw new InternalError(e);
 95         }
 96     }
 97 
 98     public double getDouble(Object obj) throws IllegalArgumentException {
 99         return getFloat(obj);
100     }
101 
102     public void set(Object obj, Object value)
103             throws IllegalArgumentException, IllegalAccessException
104     {
105         ensureObj(obj);
106         if (isReadOnly()) {
107             throwFinalFieldIllegalAccessException(value);
108         }
109 

166 
167     public void setLong(Object obj, long l)
168         throws IllegalArgumentException, IllegalAccessException
169     {
170         setFloat(obj, l);
171     }
172 
173     public void setFloat(Object obj, float f)
174         throws IllegalArgumentException, IllegalAccessException
175     {
176         if (isReadOnly()) {
177             ensureObj(obj);     // throw NPE if obj is null on instance field
178             throwFinalFieldIllegalAccessException(f);
179         }
180         try {
181             if (isStatic()) {
182                 setter.invokeExact(f);
183             } else {
184                 setter.invokeExact(obj, f);
185             }
186         } catch (IllegalArgumentException|IllegalStateException|NullPointerException e) {
187             throw e;
188         } catch (ClassCastException e) {
189             // receiver is of invalid type
190             throw newSetIllegalArgumentException(obj);
191         } catch (Throwable e) {
192             throw new InternalError(e);
193         }
194     }
195 
196     public void setDouble(Object obj, double d)
197         throws IllegalArgumentException, IllegalAccessException
198     {
199         throwSetIllegalArgumentException(d);
200     }
201 }
< prev index next >