src/share/classes/java/lang/Class.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 6642881_8u40_jdk Cdiff src/share/classes/java/lang/Class.java

src/share/classes/java/lang/Class.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) 1994, 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) 1994, 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
*** 128,142 **** static { registerNatives(); } /* ! * Constructor. Only the Java Virtual Machine creates Class ! * objects. ! */ ! private Class() {} ! /** * Converts the object to a string. The string representation is the * string "class" or "interface", followed by a space, and then by the * fully qualified name of the class in the format returned by --- 128,146 ---- static { registerNatives(); } /* ! * Private constructor. Only the Java Virtual Machine creates Class objects. ! * This constructor is not used and prevents the default constructor being ! * generated. ! */ ! private Class(ClassLoader loader) { ! // Initialize final field for classLoader. The initialization value of non-null ! // prevents future JIT optimizations from assuming this final field is null. ! classLoader = loader; ! } /** * Converts the object to a string. The string representation is the * string "class" or "interface", followed by a space, and then by the * fully qualified name of the class in the format returned by
*** 675,686 **** } return cl; } // Package-private to allow ClassLoader access ! native ClassLoader getClassLoader0(); /** * Returns an array of {@code TypeVariable} objects that represent the * type variables declared by the generic declaration represented by this * {@code GenericDeclaration} object, in declaration order. Returns an --- 679,692 ---- } return cl; } // Package-private to allow ClassLoader access ! ClassLoader getClassLoader0() { return classLoader; } + // Initialized in JVM not by private constructor + private final ClassLoader classLoader; /** * Returns an array of {@code TypeVariable} objects that represent the * type variables declared by the generic declaration represented by this * {@code GenericDeclaration} object, in declaration order. Returns an
src/share/classes/java/lang/Class.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File