< prev index next >

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

Print this page

 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         throw newGetIntIllegalArgumentException();
 76     }
 77 
 78     public long getLong(Object obj) throws IllegalArgumentException {
 79         try {
 80             if (isStatic()) {
 81                 return (long) getter.invokeExact();
 82             } else {
 83                 return (long) getter.invokeExact(obj);
 84             }
 85         } catch (IllegalArgumentException|NullPointerException e) {
 86             throw e;
 87         } catch (ClassCastException e) {
 88             throw newGetIllegalArgumentException(obj);
 89         } catch (Throwable e) {
 90             throw new InternalError(e);
 91         }
 92     }
 93 
 94     public float getFloat(Object obj) throws IllegalArgumentException {
 95         return getLong(obj);
 96     }
 97 
 98     public double getDouble(Object obj) throws IllegalArgumentException {
 99         return getLong(obj);
100     }
101 
102     public void set(Object obj, Object value)
103             throws IllegalArgumentException, IllegalAccessException
104     {
105         ensureObj(obj);

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

 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         throw newGetIntIllegalArgumentException();
 76     }
 77 
 78     public long getLong(Object obj) throws IllegalArgumentException {
 79         try {
 80             if (isStatic()) {
 81                 return (long) getter.invokeExact();
 82             } else {
 83                 return (long) getter.invokeExact(obj);
 84             }
 85         } catch (IllegalArgumentException|IllegalStateException|NullPointerException e) {
 86             throw e;
 87         } catch (ClassCastException e) {
 88             throw newGetIllegalArgumentException(obj);
 89         } catch (Throwable e) {
 90             throw new InternalError(e);
 91         }
 92     }
 93 
 94     public float getFloat(Object obj) throws IllegalArgumentException {
 95         return getLong(obj);
 96     }
 97 
 98     public double getDouble(Object obj) throws IllegalArgumentException {
 99         return getLong(obj);
100     }
101 
102     public void set(Object obj, Object value)
103             throws IllegalArgumentException, IllegalAccessException
104     {
105         ensureObj(obj);

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