Issue Details (XML | Word | Printable)

Key: HARMONY-5199
Type: Bug Bug
Status: Closed Closed
Resolution: Duplicate
Priority: Major Major
Assignee: Alexey Varlamov
Reporter: Alexei Fedotov
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Harmony

[drlvm][kernel] final fields cannot be set accessible

Created: 26/Nov/07 08:53 PM   Updated: 27/Nov/07 10:30 AM
Return to search
Component/s: DRLVM
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works fix_if.patch 2007-11-26 09:31 PM Alexei Fedotov 1 kB
Text File Licensed for inclusion in ASF works test_fix_if.patch 2007-11-26 09:31 PM Alexei Fedotov 2 kB
Issue Links:
Duplicate
 
Reference
 

Patch Info: Patch Available
Resolution Date: 27/Nov/07 06:14 AM


 Description  « Hide
The following simple test fails:
import java.lang.reflect.*;
public class TestField {
    final public int g = 3;
    public static void main(String[] args) throws Exception {
        TestField t = new TestField();
        Field f = t.getClass().getField("g");
        f.setAccessible(true);
        f.setInt(t, 4);
        System.out.println(t.g);
    }
}

See the last comment at http://jira.codehaus.org/browse/XSTR-379




 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Vasily Zakharov added a comment - 26/Nov/07 09:05 PM
Thanks alot for taking note of this, Alexei!

By the way, IBM VME makes the same mistake.

Vasily Zakharov added a comment - 26/Nov/07 09:08 PM
Here's the similar issue for IBM VME: HARMONY-5200.

Alexei Fedotov added a comment - 26/Nov/07 09:31 PM
The test and the fix

Vasily Zakharov added a comment - 27/Nov/07 03:05 AM
Alexei, thank you very much for the quick fix, it seems to resolve the problem with XStream.

I just wonder it it was right to remove the null check that previously existed in commented code...

Alexey Varlamov added a comment - 27/Nov/07 06:14 AM
Vasily observed right, specification states that only non-static final fields can be modified.

Alexei Fedotov added a comment - 27/Nov/07 10:30 AM
Thanks, guys. I tried to modify a static field on RI and got
java.lang.IllegalAccessException: Field is final