JDK-4386357 : private method in a final class
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2000-11-06
  • Updated: 2000-12-08
  • Resolved: 2000-12-08
Related Reports
Duplicate :  
Description

Name: boT120536			Date: 11/06/2000


java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

If you compile and run the following program it indicates that the value of the
modifiers on method m is 2 and om is zero indicating that the method m is
private and method pm has default access, however the JLS (2nd Ed) on page 172
section 8.4.3.3 states that a Private method and all methods declared in a
final class are implicitly final ......

This would appear to indicate that the modifier values for m should be 0x12 and
0x10 for pm.


import java.lang.reflect.*;

final class fc
{

	private  int m(){ return 1;}

	private class Inner {
		int pm(){ return 20;}
	}


	public static void main(String argv[])
	{

		try {
			Class cx = fc.class;
			java.lang.reflect.Method mt = cx.getDeclaredMethod("m",
null);
			System.out.println("Modifiers for m are "+
mt.getModifiers());

			cx = Inner.class;
			mt = cx.getDeclaredMethod("pm", null);
			System.out.println("Modifiers for pm are "+
mt.getModifiers());

		}catch(Exception e) {
			e.printStackTrace();
		}

	}

}
(Review ID: 111557) 
======================================================================

Comments
EVALUATION This is a duplicate of bug 4249112. If I recall correctly, there were some serialization compatibility issues that came up when addressing that bug so I kind of doubt that it will be possible to actually set the ACC_FINAL bit but it probably should be investigated. The associated regression test which tests for these cases is test/tools/javac/ClassFileModifiers/MemberModifiers.java. iris.garcia@eng 2000-12-06 There is another issue raised by this bug - method pm is not a method OF a final class, but it does appear IN a final class. I think this is a minor type on the specification - pm should not be final. neal.gafter@Eng 2000-12-08
08-12-2000