< prev index next >

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

Print this page

 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         throw newGetFloatIllegalArgumentException();
 84     }
 85 
 86     public double getDouble(Object obj) throws IllegalArgumentException {
 87         try {
 88             if (isStatic()) {
 89                 return (double) getter.invokeExact();
 90             } else {
 91                 return (double) getter.invokeExact(obj);
 92             }
 93         } catch (IllegalArgumentException|NullPointerException e) {
 94             throw e;
 95         } catch (ClassCastException e) {
 96             throw newGetIllegalArgumentException(obj);
 97         } catch (Throwable e) {
 98             throw new InternalError(e);
 99         }
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 
110         if (value == null) {
111             throwSetIllegalArgumentException(value);
112         }
113 

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

 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         throw newGetFloatIllegalArgumentException();
 84     }
 85 
 86     public double getDouble(Object obj) throws IllegalArgumentException {
 87         try {
 88             if (isStatic()) {
 89                 return (double) getter.invokeExact();
 90             } else {
 91                 return (double) getter.invokeExact(obj);
 92             }
 93         } catch (IllegalArgumentException|IllegalStateException|NullPointerException e) {
 94             throw e;
 95         } catch (ClassCastException e) {
 96             throw newGetIllegalArgumentException(obj);
 97         } catch (Throwable e) {
 98             throw new InternalError(e);
 99         }
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 
110         if (value == null) {
111             throwSetIllegalArgumentException(value);
112         }
113 

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