JDK-8133168 : Visibility bridge methods cannot be added for final methods
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 8u51,9,25
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_8
  • CPU: x86
  • Submitted: 2015-08-03
  • Updated: 2025-12-05
  • Resolved: 2025-12-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdResolved
Related Reports
Duplicate :  
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.3.9600]

A DESCRIPTION OF THE PROBLEM :
javac adds visibility bridges to work around limitations of the reflection system when inheriting public methods of non-public types.

This does not work for final methods: https://gist.github.com/raphw/7d10ae082ace5886d601

REGRESSION.  Last worked in version 8u51

ADDITIONAL REGRESSION INFORMATION: 
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
https://gist.github.com/raphw/7d10ae082ace5886d601

Compile and run to reproduce error.

EXPECTED VERSUS ACTUAL BEHAVIOUR :
EXPECTED -
Should not throw an exception for final methods.
ACTUAL -
Throws an exception

ERROR MESSAGES/STACK TRACES THAT OCCUR :
IllegalAccessException

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
https://gist.github.com/raphw/7d10ae082ace5886d601
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
No work around possible due to final method.


Comments
This is due to JDK-4283544. Let's track it there.
05-12-2025

Tested on current JDK and still reproduces. However, I don't think this has to do with javac at all - this is a core reflection issue. I wonder why this was considered to be a javac issue before. JDK-8172815 and JDK-8172817 describes similar problems.
11-07-2025

To reassess post nestmate integration (see JDK-8046171)
20-12-2017

Converted to RFE - can we improve the accessibility story so that accessibility bridges are no longer needed?
17-11-2015

I get this on JDK 7 as well: java.lang.IllegalAccessException: Class VisibilityBridgeTest can not access a member of class foo.Base with modifiers "public final" at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:110) at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:262) at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:254) at java.lang.reflect.Method.invoke(Method.java:599) at VisibilityBridgeTest.testFinalMethod(VisibilityBridgeTest.java:7) at VisibilityBridgeTest.main(VisibilityBridgeTest.java:18) This bug has probably been there since JDK 5. Compiling it with other compilers lead to same problem.
17-11-2015

Not quite sure what could javac do about this - javac cannot generate the bridge, as the method is final.
03-11-2015

I agree with Jan, however I'm curious as to why this bug has been marked as a regression from 8u51 - if the issue impacting the user has to do with missing visibility bridge for final methods, then it surely has to be a problem that affects all releases?
03-11-2015

- Run the attached files (Foo.java and VisibilityBridgeTest.java)in Windows 7 (64-bit) - Checked this for JDK 8u51, 8u60 ea b26 and 9 ea b75 and couldn't reproduce the issue. - The code compiles fine without an exception JDK 8-all and 9 ea. Closing this as cannot reproduce.
06-08-2015