src/share/classes/java/lang/reflect/AccessibleObject.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
6642881_8u40_jdk Cdiff src/share/classes/java/lang/reflect/AccessibleObject.java
src/share/classes/java/lang/reflect/AccessibleObject.java
Print this page
rev 9948 : 6642881: Improve performance of Class.getClassLoader()
Summary: Add classLoader to java/lang/Class instance for fast access
Reviewed-by: alanb, lfoltan, rriggs, vlivanov, twisti, mchung, jfranck, dholmes
*** 1,7 ****
/*
! * Copyright (c) 1997, 2013, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1997, 2014, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 127,146 ****
SecurityManager sm = System.getSecurityManager();
if (sm != null) sm.checkPermission(ACCESS_PERMISSION);
setAccessible0(this, flag);
}
! /* Check that you aren't exposing java.lang.Class.<init>. */
private static void setAccessible0(AccessibleObject obj, boolean flag)
throws SecurityException
{
if (obj instanceof Constructor && flag == true) {
Constructor<?> c = (Constructor<?>)obj;
if (c.getDeclaringClass() == Class.class) {
! throw new SecurityException("Can not make a java.lang.Class" +
" constructor accessible");
}
}
obj.override = flag;
}
/**
--- 127,154 ----
SecurityManager sm = System.getSecurityManager();
if (sm != null) sm.checkPermission(ACCESS_PERMISSION);
setAccessible0(this, flag);
}
! /* Check that you aren't exposing java.lang.Class.<init> or sensitive
! fields in java.lang.Class. */
private static void setAccessible0(AccessibleObject obj, boolean flag)
throws SecurityException
{
if (obj instanceof Constructor && flag == true) {
Constructor<?> c = (Constructor<?>)obj;
if (c.getDeclaringClass() == Class.class) {
! throw new SecurityException("Cannot make a java.lang.Class" +
" constructor accessible");
}
+ } else if (obj instanceof Field && flag == true) {
+ Field f = (Field)obj;
+ if (f.getDeclaringClass() == Class.class &&
+ f.getName().equals("classLoader")) {
+ throw new SecurityException("Cannot make java.lang.Class.classLoader" +
+ " accessible");
+ }
}
obj.override = flag;
}
/**
src/share/classes/java/lang/reflect/AccessibleObject.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File