RVM

Off-by-one error in "VMField.checkReadAccess" and "VM.checkWriteAccess"

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Fixed
  • Affects Version/s: 2.9.2
  • Fix Version/s: 2.9.3
  • Component/s: Runtime
  • Labels:
    None
  • Environment:
    prototype-opt Jikes RVM 2.9.2+svn (r14123) using GNU Classpath 0.97.1

  • Number of attachments :
    0

Description

In both "java.lang.reflect.VMField.checkReadAccess" and "java.lang.reflect.VMField.checkWriteAccess" there is an off-by-one error: the parameter to "VM_Class.getClassFromStackFrame" ought to be 3, not 2. This is exemplified by the following stack trace, taken from "TestFieldReflection" (part of the "basic" test suite):

Values:java.lang.IllegalAccessException: Access to < SystemAppCL, Ltest/org/jikesrvm/basic/core/reflect/TestFieldReflection$TypeWithDifferentAccessModifiers; >.mbyte B is denied to java.lang.reflect.Field
at .<invisible method>(Unknown Source:0)
at java.lang.VMThrowable.fillInStackTrace(VMThrowable.java:49)
at java.lang.Throwable.fillInStackTrace(Throwable.java:498)
at java.lang.Throwable.<init>(Throwable.java:159)
at java.lang.Exception.<init>(Exception.java:78)
at java.lang.IllegalAccessException.<init>(IllegalAccessException.java:97)
at java.lang.reflect.JikesRVMSupport.checkAccess(JikesRVMSupport.java:147)
at java.lang.reflect.VMField.checkReadAccess(VMField.java:245)
at java.lang.reflect.VMField.get(VMField.java:57)
at java.lang.reflect.Field.get(Field.java:261)
at test.org.jikesrvm.basic.core.reflect.TestFieldReflection.printFields(TestFieldReflection.java:128)
at test.org.jikesrvm.basic.core.reflect.TestFieldReflection.testFieldReflection(TestFieldReflection.java:75)
at test.org.jikesrvm.basic.core.reflect.TestFieldReflection.testFieldReflection(TestFieldReflection.java:69)
at test.org.jikesrvm.basic.core.reflect.TestFieldReflection.main(TestFieldReflection.java:61)

Here, "test.org.jikesrvm.basic.core.reflect.TestFieldReflection" ought to be considered the accessing class.

FWIW, tracking this rather minor error down was made hard by the fact that the "diffCompareFiles" macro in "build/tests.xml" does not report failures correctly if the "execution" property is not set properly, e.g., during a "tiny" test-run.

Activity

Hide
David Grove added a comment -

Confirmed that: (1) we are failing this test and (2) the test harness is not properly detecting it.

Nice catch; thanks!

Show
David Grove added a comment - Confirmed that: (1) we are failing this test and (2) the test harness is not properly detecting it. Nice catch; thanks!
Hide
David Grove added a comment -

fixed in r14154.

Show
David Grove added a comment - fixed in r14154.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: