Name: gm110360 Date: 06/08/2004
FULL PRODUCT VERSION :
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b51)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b51, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
A private final int variable of a class can be modified via reflection
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
just execute the source below
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
an IllegalAccessException should be thrown
ACTUAL -
the value can be set without exception
ERROR MESSAGES/STACK TRACES THAT OCCUR :
---none---
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.lang.reflect.*;
public class Test
{
public static void main(String[] tooralooraloo) throws Throwable
{
Change change = new Change(42);
System.out.println("before: "+change);
Field f = change.getClass().getDeclaredField("number");
f.setAccessible(true);
f.set(change, new Integer(666) );
System.out.println("after: "+change);
}
}
class Change
{
private final int number;
Change(int x)
{
number = x;
}
public String toString()
{
return number + "";
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
---none---
Release Regression From : 1.4.2
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
(Incident Review ID: 276697)
======================================================================