8081695: Old verifier fails to reject bad access to protected <init> method
authorhseigel
Fri, 24 Jul 2015 10:03:58 -0400
changeset 32023 864c0bdf9b06
parent 32022 c692b17ea891
child 32024 90a60a8aedfc
8081695: Old verifier fails to reject bad access to protected <init> method Summary: Remove the class file version check that prevented the proper access check Reviewed-by: coleenp, gtriantafill, lfoltan
jdk/src/java.base/share/native/libverify/check_code.c
jdk/test/vm/verifier/VerifyProtectedConstructor.java
--- a/jdk/src/java.base/share/native/libverify/check_code.c	Thu Jul 23 21:33:57 2015 +0200
+++ b/jdk/src/java.base/share/native/libverify/check_code.c	Fri Jul 24 10:03:58 2015 -0400
@@ -2407,7 +2407,6 @@
                         CCerror(context, "Call to wrong initialization method");
                     }
                     if (this_idata->protected
-                        && context->major_version > LDC_CLASS_MAJOR_VERSION
                         && !isAssignableTo(context, object_type,
                                            context->currentclass_info)) {
                       CCerror(context, "Bad access to protected data");
--- a/jdk/test/vm/verifier/VerifyProtectedConstructor.java	Thu Jul 23 21:33:57 2015 +0200
+++ b/jdk/test/vm/verifier/VerifyProtectedConstructor.java	Fri Jul 24 10:03:58 2015 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
  * @test
 
  * @bug 6490436
- * @summary Verify that protected constructor calls are not allowed for classfile version >= 50 (but that they are allowed for lesser versions).
+ * @summary Verify that protected constructor calls are not allowed for any classfile versions in either verifier.
  * @author Keith McGuigan
  */
 
@@ -38,9 +38,10 @@
 
     try {
       t.checkClassVersion(49); // should not throw VerifyError
+      throw new Exception("FAIL: should be a VerifyError for CF version 49");
     }
     catch(VerifyError e) {
-       throw new Exception("FAIL: should be no VerifyError for CF version 49");
+       System.out.println("PASS for CF version 49");
     }
 
     try {