Code example for Field

Methods: getLong, setLong

0
                val);
        
      //test wrong type 
        boolean thrown = false;
        try { 
            f = x.getClass().getDeclaredField("booleanField");
            f.setDouble(x, Double.MIN_VALUE);
            fail("Accessed field of invalid type");
        } catch (IllegalArgumentException ex) {
            thrown = true;
        } 
        assertTrue("IllegalArgumentException expected but not thrown", thrown);
         
        //test not accessible 
        thrown = false;
        try { 
            f = x.getClass().getDeclaredField("doublePFField");
            assertFalse(f.isAccessible());
            f.setDouble(x, Double.MIN_VALUE);
            fail("Accessed inaccessible field");
        } catch (IllegalAccessException ex) {