changeset 12509:2b2e654d6da4

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
author hseigel
date Fri, 24 Jul 2015 10:03:58 -0400
parents 422b9329070d
children 9d2eb1f939c3
files src/java.base/share/native/libverify/check_code.c test/vm/verifier/VerifyProtectedConstructor.java
diffstat 2 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/native/libverify/check_code.c	Thu Jul 23 21:33:57 2015 +0200
+++ b/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/test/vm/verifier/VerifyProtectedConstructor.java	Thu Jul 23 21:33:57 2015 +0200
+++ b/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 {