changeset 51832:e2bf86b88863

8205491: adjust reflective access checks Reviewed-by: alanb, mchung, igerasim, rhalade, ahgross
author smarks
date Fri, 22 Jun 2018 17:08:00 -0700
parents e9bbd853944d
children 3c0a5bf931e4
files src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java	Thu Jun 07 18:21:29 2018 +0530
+++ b/src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java	Fri Jun 22 17:08:00 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2018, 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
@@ -453,11 +453,11 @@
             }
             return false;
         } else {
-            // accessible if the parent is public and any constructor
-            // is protected or public
-            if ((superCl.getModifiers() & Modifier.PUBLIC) == 0) {
+            // sanity check to ensure the parent is protected or public
+            if ((superCl.getModifiers() & (Modifier.PROTECTED | Modifier.PUBLIC)) == 0) {
                 return false;
             }
+            // accessible if any constructor is protected or public
             for (Constructor<?> ctor : superCl.getDeclaredConstructors()) {
                 if ((ctor.getModifiers() & (Modifier.PROTECTED | Modifier.PUBLIC)) != 0) {
                     return true;