100+ results for 'Reflection.getCallerClass'

Not the results you expected?

AtomicLongFieldUpdater.java (https://github.com/rhuitl/uClinux.git) Java · 406 lines

244 try {

245 field = tclass.getDeclaredField(fieldName);

246 caller = sun.reflect.Reflection.getCallerClass(3);

247 modifiers = field.getModifiers();

248 sun.reflect.misc.ReflectUtil.ensureMemberAccess(

327 try {

328 field = tclass.getDeclaredField(fieldName);

329 caller = sun.reflect.Reflection.getCallerClass(3);

330 modifiers = field.getModifiers();

331 sun.reflect.misc.ReflectUtil.ensureMemberAccess(

AtomicLongFieldUpdater.java (https://bitbucket.org/codefirex/toolchain_gcc-4.9.git) Java · 406 lines

244 try {

245 field = tclass.getDeclaredField(fieldName);

246 caller = sun.reflect.Reflection.getCallerClass(3);

247 modifiers = field.getModifiers();

248 sun.reflect.misc.ReflectUtil.ensureMemberAccess(

327 try {

328 field = tclass.getDeclaredField(fieldName);

329 caller = sun.reflect.Reflection.getCallerClass(3);

330 modifiers = field.getModifiers();

331 sun.reflect.misc.ReflectUtil.ensureMemberAccess(

Daemon.java (https://github.com/babitha/openmrs.git) Java · 254 lines

99

100 // quick check to make sure we're only being called by ourselves

101 //Class<?> callerClass = Reflection.getCallerClass(0);

102 Class<?> callerClass = new OpenmrsSecurityManager().getCallerClass(0);

103 if (!TimerSchedulerTask.class.isAssignableFrom(callerClass))

FieldReflection.java (https://github.com/stuartwdouglas/fakereplace.git) Java · 374 lines

204 FieldAccessor accessor = ClassDataStore.instance().getFieldAccessor(f.getDeclaringClass().getName());

205 if (!Modifier.isPublic(f.getModifiers()) && !f.isAccessible()) {

206 Class<?> caller = sun.reflect.Reflection.getCallerClass(2);

207 Reflection.ensureMemberAccess(caller, accessor.getDeclaringClass(), null, f.getModifiers());

208 }

213 FieldAccessor accessor = ClassDataStore.instance().getFieldAccessor(f.getDeclaringClass().getName());

214 if (!Modifier.isPublic(f.getModifiers()) && !f.isAccessible()) {

215 Class<?> caller = sun.reflect.Reflection.getCallerClass(2);

216 Reflection.ensureMemberAccess(caller, accessor.getDeclaringClass(), null, f.getModifiers());

217 }

222 FieldAccessor accessor = ClassDataStore.instance().getFieldAccessor(f.getDeclaringClass().getName());

223 if (!Modifier.isPublic(f.getModifiers()) && !f.isAccessible()) {

224 Class<?> caller = sun.reflect.Reflection.getCallerClass(2);

225 Reflection.ensureMemberAccess(caller, accessor.getDeclaringClass(), null, f.getModifiers());

226 }

AtomicIntegerFieldUpdater.java (https://gitlab.com/lobl.pavel/gcc-6.2.0) Java · 316 lines

245 try {

246 field = tclass.getDeclaredField(fieldName);

247 caller = sun.reflect.Reflection.getCallerClass(3);

248 modifiers = field.getModifiers();

249 sun.reflect.misc.ReflectUtil.ensureMemberAccess(

AtomicIntegerFieldUpdater.java (https://github.com/zxiaofan/JDK.git) Java · 318 lines

247 try {

248 field = tclass.getDeclaredField(fieldName);

249 caller = sun.reflect.Reflection.getCallerClass(3);

250 modifiers = field.getModifiers();

251 sun.reflect.misc.ReflectUtil.ensureMemberAccess(

ImageLoader.java (https://github.com/TrevorBender/intellij-community.git) Java · 112 lines

54 public static Image loadFromResource(@NonNls String s) {

55 int stackFrameCount = 2;

56 Class callerClass = Reflection.getCallerClass(stackFrameCount);

57 while (callerClass != null && callerClass.getClassLoader() == null) { // looks like a system class

58 callerClass = Reflection.getCallerClass(++stackFrameCount);

59 }

60 if (callerClass == null) {

61 callerClass = Reflection.getCallerClass(1);

62 }

63 return loadFromResource(s, callerClass);

PACLClassUtil.java (https://github.com/lululiferay/liferay-portal.git) Java · 300 lines

170

171 for (int i = 1;; i++) {

172 Class<?> callerClass = Reflection.getCallerClass(i);

173

174 if (callerClass == null) {

SecurityChecker.java (https://github.com/lululiferay/liferay-portal.git) Java · 207 lines

58

59 protected boolean hasGetPolicy() {

60 Class<?> callerClass8 = Reflection.getCallerClass(8);

61

62 if (isGlassfishJ2EEInstanceListener(

79

80 protected boolean hasSetPolicy() {

81 Class<?> callerClass6 = Reflection.getCallerClass(6);

82

83 if (isGlassfishPolicyContextHandlerImpl(callerClass6)) {

87 }

88

89 Class<?> callerClass7 = Reflection.getCallerClass(7);

90

91 if (isGeronimoDispatchListener(callerClass7)) {

ReflectionComparison.java (https://gitlab.com/essere.lab.public/qualitas.class-corpus) Java · 130 lines

32

33 /**

34 * Tests the cost of invoking Reflection.getCallerClass via reflection vs calling it directly.

35 */

36 public class ReflectionComparison {

81 for (int i= 0; i < COUNT; ++i) {

82

83 Reflection.getCallerClass(3);

84 }

85 timer.stop();

JDOMExternalizableStringList.java (https://github.com/maartenh/intellij-community.git) Java · 100 lines

50 add(null);

51 }

52 final ClassLoader classLoader = Reflection.getCallerClass(2).getClassLoader();

53 for (final Object o1 : listElement.getChildren()) {

54 Element listItemElement = (Element)o1;

Reflect.scala (https://github.com/migue/akka.git) Scala · 136 lines

23 * on the call stack and returns the `Class[_]` object for the code

24 * executing in that stack frame. Implemented using

25 * `sun.reflect.Reflection.getCallerClass` if available, None otherwise.

26 *

27 * Hint: when comparing to Thread.currentThread.getStackTrace, add two levels.

ReflectChecker.java (git://github.com/liferay/liferay-portal.git) Java · 123 lines

80 int stackIndex = Reflection.getStackIndex(3, 2);

81

82 Class<?> callerClass = Reflection.getCallerClass(stackIndex);

83

84 if (isTrustedCaller(callerClass, permission)) {

101 int stackIndex = Reflection.getStackIndex(4, 3);

102

103 Class<?> callerClass = Reflection.getCallerClass(stackIndex);

104

105 if (isTrustedCaller(callerClass, permission)) {

GetCallerClassTests.java (https://github.com/eclipse/openj9.git) Java · 254 lines

40

41 try {

42 sun.reflect.Reflection.getCallerClass();

43 System.out.println(TESTCASE_NAME + ": FAILED 1");

44 return false;

61

62 try {

63 sun.reflect.Reflection.getCallerClass();

64 System.out.println(TESTCASE_NAME + ": FAILED 1");

65 return false;

83

84 try {

85 sun.reflect.Reflection.getCallerClass();

86 System.out.println(TESTCASE_NAME + ": PASSED");

87 return true;

GetCallerClassTests.java (https://github.com/eclipse/openj9.git) Java · 254 lines

40

41 try {

42 jdk.internal.reflect.Reflection.getCallerClass();

43 System.out.println(TESTCASE_NAME + ": FAILED 1");

44 return false;

61

62 try {

63 jdk.internal.reflect.Reflection.getCallerClass();

64 System.out.println(TESTCASE_NAME + ": FAILED 1");

65 return false;

83

84 try {

85 jdk.internal.reflect.Reflection.getCallerClass();

86 System.out.println(TESTCASE_NAME + ": PASSED");

87 return true;

PortalRuntimeChecker.java (https://github.com/lululiferay/liferay-portal.git) Java · 236 lines

129

130 if (clazz == PortalExecutorManagerUtil.class) {

131 Class<?> callerClass10 = Reflection.getCallerClass(10);

132

133 if (callerClass10 == BaseAsyncDestination.class) {

SecurityChecker.java (https://github.com/christine-huang/liferay-portal.git) Java · 95 lines

66 int stackIndex = getStackIndex(11, 11, 10);

67

68 Class<?> callerClass = Reflection.getCallerClass(stackIndex);

69

70 if (isTrustedCaller(callerClass, permission)) {

80 int stackIndex = getStackIndex(11, 11, 10);

81

82 Class<?> callerClass = Reflection.getCallerClass(stackIndex);

83

84 if (isTrustedCaller(callerClass, permission)) {

ServletDump.java (http://google-enterprise-connector-manager.googlecode.com/svn/trunk/) Java · 129 lines ✨ Summary

This Java class, ServletDump, provides a utility method to dump the contents of an HttpServletRequest object into a human-readable XML format and write it to an HttpServletResponse object. It can be used for debugging purposes to display detailed information about incoming HTTP requests.

113 if (LOGGER.isLoggable(Level.FINE)) {

114 LOGGER.fine("HttpRequest handled by "

115 + sun.reflect.Reflection.getCallerClass(2).getName()

116 + "\ncalled by "

117 + sun.reflect.Reflection.getCallerClass(3).getName()

Security.java (https://github.com/an1310/infinispan.git) Java · 200 lines

37 int offset = 0;

38 try {

39 result = Reflection.getCallerClass(1) == Security.class || Reflection.getCallerClass(2) == Security.class;

40 offset = Reflection.getCallerClass(1) == Reflection.class ? 2 : 1;

193 static Class<?> getCallerClass(int n) {

194 if (hasGetCallerClass) {

195 return Reflection.getCallerClass(n + callerOffset);

196 } else {

197 return SECURITY_MANAGER.getClasses()[n + callerOffset];

inti.patch (https://github.com/ohpauleez/soymacchiato.git) Patch · 147 lines

62 + if (current == null)

63 + throw new IllegalStateException("Not called from interface class initializer.");

64 + Class cc = sun.reflect.Reflection.getCallerClass(2);

65 + if (cc != current.iface)

66 + throw new IllegalStateException("Not called from interface class initializer.");

LogUtil.java (https://github.com/nothize/suite.git) Java · 84 lines

23

24 public static void initLog4j(Level level) {

25 String caller = Reflection.getCallerClass(2).getSimpleName();

26

27 PatternLayout layout = new PatternLayout("%d %-5p [%c{1}] %m%n");

ClassLoaderUtils.java (https://github.com/naver/pinpoint.git) Java · 118 lines

55 }

56

57 // TODO check @CallerSensitive, Reflection.getCallerClass()

58 // private static ClassLoader getClassLoader(ClassLoader classLoader) {

59 // if (classLoader == null) {

FileLoader.java (https://github.com/Oshan96/CustomStage.git) Java · 191 lines

46 this.ext = ext;

47 try {

48 // Class clazz = sun.reflect.Reflection.getCallerClass(2);

49 Class clazz = Class.forName(new Throwable().getStackTrace()[3].getClassName());

50 dir = new File(clazz.getProtectionDomain().getCodeSource().getLocation().getPath()).toString().replace("%20"," ");

PortalServiceChecker.java (git://github.com/liferay/liferay-portal.git) Java · 184 lines

119 int stackIndex = Reflection.getStackIndex(8, 7);

120

121 Class<?> callerClass = Reflection.getCallerClass(stackIndex);

122

123 if (isTrustedCaller(callerClass, permission)) {

124 callerClass = Reflection.getCallerClass(stackIndex + 1);

125

126 if (isTrustedCaller(callerClass, permission)) {

ReflectionGetCallerClassNode.java (https://github.com/oracle/graal.git) Java · 115 lines

86 // Cf. JVM_GetCallerClass

87 // NOTE: Start the loop at depth 1 because the current frame state does

88 // not include the Reflection.getCallerClass() frame.

89 for (int n = 1; state != null; state = state.outerFrameState(), n++) {

90 ResolvedJavaMethod method = state.getMethod();

91 switch (n) {

92 case 0:

93 throw GraalError.shouldNotReachHere("current frame state does not include the Reflection.getCallerClass frame");

94 case 1:

95 // Frame 0 and 1 must be caller sensitive (see JVM_GetCallerClass).

NetChecker.java (https://github.com/christine-huang/liferay-portal.git) Java · 86 lines

61 int stackIndex = getStackIndex(11, 10);

62

63 Class<?> callerClass = Reflection.getCallerClass(stackIndex);

64

65 if (isTrustedCaller(callerClass, permission)) {

73 int stackIndex = getStackIndex(11, 10);

74

75 Class<?> callerClass = Reflection.getCallerClass(stackIndex);

76

77 if (isTrustedCaller(callerClass, permission)) {

GetCallerClassTest.java (https://github.com/openjdk/jdk.git) Java · 124 lines

25 * @test

26 * @bug 8010117

27 * @summary Test if the VM enforces Reflection.getCallerClass

28 * be called by methods annotated with CallerSensitive

29 * @modules java.base/jdk.internal.reflect

49 ensureAnnotationPresent(boot.GetCallerClass.class, "getCallerLoader", true);

50 ensureAnnotationPresent(GetCallerClassTest.class, "testNonSystemMethod", false);

51 // call Reflection.getCallerClass from bootclasspath with and without @CS

52 gcct.testCallerSensitiveMethods();

53 // call Reflection.getCallerClass from classpath with @CS

94 private void testNonSystemMethod() {

95 try {

96 Class<?> c = Reflection.getCallerClass();

97 throw new RuntimeException("@CallerSensitive testNonSystemMethods not supported");

98 } catch (InternalError e) {

NetChecker.java (https://github.com/lululiferay/liferay-portal.git) Java · 92 lines

48 protected boolean hasGetProxySelector() {

49 if (JavaDetector.isJDK7()) {

50 Class<?> callerClass8 = Reflection.getCallerClass(8);

51

52 String className8 = callerClass8.getName();

61 }

62 else {

63 Class<?> callerClass7 = Reflection.getCallerClass(7);

64

65 String className7 = callerClass7.getName();

UIDefaultsLookup.java (git://pkgs.fedoraproject.org/jide-oss) Java · 415 lines

70 }

71

72 // NOTE use of more generic Reflection.getCallerClass()

73 Class caller = Reflection.getCallerClass(3);

UnsafeSupport.java (https://github.com/yangjiandong/sshapp.git) Java · 79 lines

31 * public static Unsafe getUnsafe()

32 * {

33 * Class localClass = Reflection.getCallerClass(2);

34 * if (localClass.getClassLoader() != null)

35 * throw new SecurityException(&quot;Unsafe&quot;);

VerifyCallerSensitiveMethods.java (https://github.com/zxiaofan/JDK.git) Java · 97 lines

74 if (annotation == null) {

75 StackTraceElement e = graph.method().asStackTraceElement(invoke.bci());

76 throw new VerificationError(String.format("%s: method that calls Reflection.getCallerClass() must be annotated with @CallerSensitive", e));

77 }

78

79 } else if (annotation != null) {

80 throw new VerificationError(String.format("%s: method annotated with @CallerSensitive does not call Reflection.getCallerClass()", graph.method().format("%H.%n(%p)")));

81 }

82 return true;

ReflectionGetCallerClassNode.java (https://github.com/zxiaofan/JDK.git) Java · 117 lines

91 // Cf. JVM_GetCallerClass

92 // NOTE: Start the loop at depth 1 because the current frame state does

93 // not include the Reflection.getCallerClass() frame.

94 for (int n = 1; state != null; state = state.outerFrameState(), n++) {

95 HotSpotResolvedJavaMethod method = (HotSpotResolvedJavaMethod) state.getMethod();

96 switch (n) {

97 case 0:

98 throw GraalError.shouldNotReachHere("current frame state does not include the Reflection.getCallerClass frame");

99 case 1:

100 // Frame 0 and 1 must be caller sensitive (see JVM_GetCallerClass).

CallerSensitive.java (https://gitlab.com/borneywpf/openjdk-7-src) Java · 41 lines

31 /**

32 * A method annotated @CallerSensitive is sensitive to its calling class,

33 * via {@link sun.reflect.Reflection#getCallerClass Reflection.getCallerClass},

34 * or via some equivalent.

35 *

MissingCallerSensitive.java (https://github.com/openjdk/jdk.git) Java · 71 lines

61 @CallerSensitive

62 public ClassLoader getCallerLoader() {

63 Class<?> c = Reflection.getCallerClass();

64 return c.getClassLoader();

65 }

66

67 public ClassLoader missingCallerSensitiveAnnotation() {

68 Class<?> c = Reflection.getCallerClass();

69 return c.getClassLoader();

70 }

ReflectChecker.java (https://github.com/christine-huang/liferay-portal.git) Java · 48 lines

33 int stackIndex = getStackIndex(10, 9);

34

35 Class<?> callerClass = Reflection.getCallerClass(stackIndex);

36

37 if (isTrustedCaller(callerClass, permission)) {

NetChecker.java (git://github.com/liferay/liferay-portal.git) Java · 87 lines

62 int stackIndex = Reflection.getStackIndex(4, 3);

63

64 Class<?> callerClass = Reflection.getCallerClass(stackIndex);

65

66 if (isTrustedCaller(callerClass, permission)) {

74 int stackIndex = Reflection.getStackIndex(4, 3);

75

76 Class<?> callerClass = Reflection.getCallerClass(stackIndex);

77

78 if (isTrustedCaller(callerClass, permission)) {

CheckerUtil.java (https://github.com/lululiferay/liferay-portal.git) Java · 54 lines

29 frame++;

30

31 Class<?> callerClass = Reflection.getCallerClass(frame);

32

33 if (callerClass != AccessController.class) {

SerialJavaObject.java (https://github.com/zxiaofan/JDK.git) Java · 173 lines

136 * If access is denied, throw a SecurityException.

137 */

138 Class<?> caller = sun.reflect.Reflection.getCallerClass();

139 if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(),

140 c.getClassLoader())) {

VerifyCallerSensitiveMethods.java (https://github.com/zxiaofan/JDK.git) Java · 96 lines

74 if (annotation == null) {

75 StackTraceElement e = graph.method().asStackTraceElement(invoke.bci());

76 throw new VerificationError(String.format("%s: method that calls Reflection.getCallerClass() must be annotated with @CallerSensitive", e));

77 }

78

79 } else if (annotation != null) {

80 throw new VerificationError(String.format("%s: method annotated with @CallerSensitive does not call Reflection.getCallerClass()", graph.method().format("%H.%n(%p)")));

81 }

82 }

Logger.java (https://github.com/automvc/honey.git) Java · 435 lines

47 String callerClass = "";

48 try {

49 callerClass = sun.reflect.Reflection.getCallerClass().getName();

50 } catch (Error e) {

51 try {

52 callerClass = sun.reflect.Reflection.getCallerClass(2).getName();

53 } catch (Throwable t) {

54 try {

162 String callerClass = "";

163 try {

164 callerClass = sun.reflect.Reflection.getCallerClass().getName();

165 } catch (Error e) {

166 try {

CallerId.java (https://github.com/wburns/infinispan.git) Java · 40 lines

12 int offset = 1;

13 try {

14 result = Reflection.getCallerClass(1) == CallerId.class || Reflection.getCallerClass(2) == CallerId.class;

15 offset = Reflection.getCallerClass(1) == Reflection.class ? 2 : 1;

33 public static Class<?> getCallerClass(int n) {

34 if (hasGetCallerClass) {

35 return Reflection.getCallerClass(n + callerOffset);

36 } else {

37 return SECURITY_MANAGER.getClasses()[n + callerOffset];

GetCallerClassTest.java (https://github.com/corretto/corretto-11.git) Java · 113 lines

38 ensureAnnotationPresent(boot.GetCallerClass.class, "getCallerLoader", true);

39 ensureAnnotationPresent(GetCallerClassTest.class, "testNonSystemMethod", false);

40 // call Reflection.getCallerClass from bootclasspath with and without @CS

41 gcct.testCallerSensitiveMethods();

42 // call Reflection.getCallerClass from classpath with @CS

83 private void testNonSystemMethod() {

84 try {

85 Class<?> c = Reflection.getCallerClass();

86 throw new RuntimeException("@CallerSensitive testNonSystemMethods not supported");

87 } catch (InternalError e) {

CallerSensitiveClass.java (https://github.com/eclipse/openj9.git) Java · 32 lines

25 @sun.reflect.CallerSensitive

26 public void callerSensitiveMethod() {

27 Class<?> c = sun.reflect.Reflection.getCallerClass();

28 if (c.getClassLoader() != null) {

29 throw new SecurityException();

CallerSensitive.java (https://github.com/openjdk/jdk.git) Java · 41 lines

31 /**

32 * A method annotated @CallerSensitive is sensitive to its calling class,

33 * via {@link jdk.internal.reflect.Reflection#getCallerClass Reflection.getCallerClass},

34 * or via some equivalent.

35 *

CSM.java (https://github.com/openjdk/jdk.git) Java · 77 lines

55 @CallerSensitive

56 public static Class<?> caller() {

57 Class<?> c1 = Reflection.getCallerClass();

58

59 try {

Reflection.java (git://github.com/liferay/liferay-portal.git) Java · 126 lines

42

43 try {

44 sun.reflect.Reflection.getCallerClass(1);

45 }

46 catch (UnsupportedOperationException uoe) {

57 // This operation is faster, so leave it here for legacy versions

58

59 return sun.reflect.Reflection.getCallerClass(depth + 2);

60 }

61

63

64 // [0] Reflection._getCallerClass

65 // [1] Reflection.getCallerClass

66

67 return callerClasses[depth + 1];

DataManagerPlugin.java (https://github.com/CovertJaguar/Railcraft.git) Java · 166 lines

152

153 public static <T> DataParameter<T> create(DataSerializer<T> serializer) {

154 DataParameter<T> dataParameter = EntityDataManager.createKey(Reflection.getCallerClass(1), serializer);

155 Logger.INSTANCE.msg(Level.WARN, "This is NOT an error. Its just Forge being nosy.");

156 return dataParameter;

Reflection.java (https://github.com/zxiaofan/JDK.git) Java · 46 lines

36 */

37 @Deprecated(forRemoval=true)

38 @SuppressWarnings("removal") // Reflection.getCallerClass

39 public static Class<?> getCallerClass(int depth) {

40 if (depth < 0)

42

43 // increase depth to account for delegation to the internal impl

44 return jdk.internal.reflect.Reflection.getCallerClass(depth + 1);

45 }

46 }

ArrayMarshaller.java (https://bitbucket.org/mirror/apache-directory-server.git) Java · 203 lines

146 public ArrayTree<E> deserialize( byte[] data ) throws IOException

147 {

148 //LOG.debug( "Deserializing the tree, called by {}", Reflection.getCallerClass( 2 ).getSimpleName() );

149

150 try

LoggerFactory.java (https://github.com/DanielLukic/idea-simple-syntax.git) Java · 36 lines

15 public static final Logger getLogger()

16 {

17 final Class callerClass = Reflection.getCallerClass( 2 );

18 if ( theKnownLoggers.containsKey( callerClass ) == false )

19 {

Unsafe.java (https://github.com/google/desugar_jdk_libs.git) Java · 835 lines

57 */

58 public static Unsafe getUnsafe() {

59 Class<?> caller = Reflection.getCallerClass();

60 /*

61 * Only code on the bootclasspath is allowed to get at the

CallerSensitiveClass.java (https://github.com/eclipse/openj9.git) Java · 32 lines

25 @jdk.internal.reflect.CallerSensitive

26 public void callerSensitiveMethod() {

27 Class<?> c = jdk.internal.reflect.Reflection.getCallerClass();

28 if (c.getClassLoader() != null) {

29 throw new SecurityException();

CallerSensitiveAdapter.java (https://github.com/openjdk/valhalla.git) Java · 112 lines

53 * @CallerSensitive

54 * static Class<?> returnCallerClass() {

55 * return returnCallerClass(Reflection.getCallerClass());

56 * }

57 * @CallerSensitiveAdapter

TestGetCallerClassName.java (https://github.com/happyyangyuan/xian.git) Java · 120 lines

22 private static class ReflectionMethod extends GetCallerClassNameMethod {

23 public String getCallerClassName(int callStackDepth) {

24 return sun.reflect.Reflection.getCallerClass(callStackDepth).getName();

25 }

26

GetCallerClass.java (https://github.com/openjdk/jdk.git) Java · 37 lines

27 @jdk.internal.reflect.CallerSensitive

28 public ClassLoader getCallerLoader() {

29 Class<?> c = jdk.internal.reflect.Reflection.getCallerClass();

30 return c.getClassLoader();

31 }

32

33 public ClassLoader missingCallerSensitiveAnnotation() {

34 Class<?> c = jdk.internal.reflect.Reflection.getCallerClass();

35 return c.getClassLoader();

36 }

VMStack.java (https://github.com/androidmalin/AMSHook.git) Java · 115 lines

37 * @return the requested class loader, or {@code null} if this is the

38 * bootstrap class loader.

39 * @deprecated Use {@code ClassLoader.getClassLoader(sun.reflect.Reflection.getCallerClass())}.

40 * Note that that can return {@link BootClassLoader} on Android where the RI

41 * would have returned null.

InternalVMMethod.java (https://github.com/oracle/graal.git) Java · 55 lines

35 /**

36 * Annotation for types whose methods must be ignored for certain kinds of stack walks, such as by

37 * Reflection.getCallerClass(). All methods in the annotated type have the same level of visibility.

38 */

39 @Retention(RetentionPolicy.RUNTIME)

Main.java (https://github.com/openjdk/jdk.git) Java · 49 lines

36

37 // removed from jdk.unsupported in JDK 11

38 Class<?> caller = Reflection.getCallerClass(2);

39

40 // removed

MemoryAddressImpl.java (https://github.com/openjdk/valhalla.git) Java · 152 lines

122 @CallerSensitive

123 public final MemorySegment asSegment(long bytesSize, ResourceScope scope) {

124 Reflection.ensureNativeAccess(Reflection.getCallerClass());

125 return asSegment(bytesSize, null, scope);

126 }

129 @CallerSensitive

130 public final MemorySegment asSegment(long bytesSize, Runnable cleanupAction, ResourceScope scope) {

131 Reflection.ensureNativeAccess(Reflection.getCallerClass());

132 Objects.requireNonNull(scope);

133 if (bytesSize <= 0) {

GetCallerClassTest.sh (https://github.com/corretto/corretto-11.git) Shell · 70 lines

24 # @test

25 # @bug 8010117

26 # @summary Test if the VM enforces Reflection.getCallerClass

27 # be called by methods annotated with CallerSensitive

28 #

GetCallerClassWithDepth.java (https://github.com/ibmruntimes/openj9-openjdk-jdk9.git) Java · 95 lines

25 * @test

26 * @bug 8025799

27 * @summary Reflection.getCallerClass(int)

28 * @modules java.base/jdk.internal.reflect

29 * @run main GetCallerClassWithDepth

41

42 try {

43 Reflection.getCallerClass(-1);

44 throw new RuntimeException("getCallerClass(-1) should fail");

45 } catch (Error e) {

50 public Class<?> getCallerClass() {

51 // 0: Reflection 1: getCallerClass 2: Test.test 3: main

52 return Reflection.getCallerClass(3);

53 }

54

SecurityChecker.java (git://github.com/liferay/liferay-portal.git) Java · 99 lines

68 new int[] {4, 4}, new int[] {4, 3});

69

70 Class<?> callerClass = Reflection.getCallerClass(stackIndex);

71

72 if (isTrustedCaller(callerClass, permission)) {

83 new int[] {4, 4}, new int[] {4, 3});

84

85 Class<?> callerClass = Reflection.getCallerClass(stackIndex);

86

87 if (isTrustedCaller(callerClass, permission)) {

ReflectionTest.java (https://github.com/javapathfinder/jpf-core.git) Java · 65 lines

32 // since it is still used by standard libs

33 void foo (){

34 Class<?> callerCls = sun.reflect.Reflection.getCallerClass(0); // that would be getCallerClass()

35 System.out.println("-- getCallerClass(0) = " + callerCls);

36 assertTrue(callerCls.getName().equals("sun.reflect.Reflection"));

37

38 callerCls = sun.reflect.Reflection.getCallerClass(1); // foo()

39 System.out.println("-- getCallerClass(1) = " + callerCls);

40 assertTrue(callerCls.getName().equals("gov.nasa.jpf.test.vm.reflection.ReflectionTest$MyClass"));

41

42 callerCls = sun.reflect.Reflection.getCallerClass(2); // bar()

43 System.out.println("-- getCallerClass(2) = " + callerCls);

44 assertTrue(callerCls.getName().equals("gov.nasa.jpf.test.vm.reflection.ReflectionTest$MyClass"));

GetCallerClassWithDepth.java (https://github.com/ibmruntimes/openj9-openjdk-jdk9.git) Java · 94 lines

25 * @test

26 * @bug 8137058

27 * @summary Basic test for the unsupported Reflection.getCallerClass(int)

28 * @modules jdk.unsupported

29 */

40

41 try {

42 Reflection.getCallerClass(-1);

43 throw new RuntimeException("getCallerClass(-1) should fail");

44 } catch (Error e) {

49 public Class<?> getCallerClass() {

50 // 0: Reflection 1: getCallerClass 2: Test.test 3: main

51 return Reflection.getCallerClass(3);

52 }

53

Algo_SUN_REFLECTION_GETCALLERCLASS.java (https://github.com/pietrobraione/jbse.git) Java · 78 lines

56 if (classFile == null) {

57 //this should happen only if this method is invoked by the root frame

58 throw new CannotInvokeMethodInCurrentContext("The sun.reflect.Reflection.getCallerClass was invoked in a context where there is no caller (arguably the root frame).");

59 }

60

ReflectionTest.java (https://github.com/CovertJaguar/Railcraft.git) Java · 25 lines

19 for (int ii = 0; ii < 5; ii++) {

20 LogManager.getLogger("ReflectionTest").log(Level.INFO,

21 new MessageFormatMessage("{0}", Reflection.getCallerClass(ii)));

22 }

23 Assertions.assertEquals(ReflectionTest.class, Reflection.getCallerClass(0));

GetCallerClass.java (https://github.com/openjdk/valhalla.git) Java · 91 lines

33

34 public Class<?> missingCallerSensitiveAnnotation() {

35 return jdk.internal.reflect.Reflection.getCallerClass();

36 }

37

38 @jdk.internal.reflect.CallerSensitive

39 public Class<?> getCallerClass() {

40 var caller = jdk.internal.reflect.Reflection.getCallerClass();

41 out.println("caller: " + caller);

42 out.println(StackWalker.getInstance(StackWalker.Option.SHOW_HIDDEN_FRAMES).walk(toStackTrace()));

52 @jdk.internal.reflect.CallerSensitive

53 public static Class<?> getCallerClassStatic() {

54 var caller = jdk.internal.reflect.Reflection.getCallerClass();

55 out.println("caller: " + caller);

56 out.println(StackWalker.getInstance(StackWalker.Option.SHOW_HIDDEN_FRAMES).walk(toStackTrace()));

Main.java (https://github.com/ibmruntimes/openj9-openjdk-jdk9.git) Java · 45 lines

32 public static void main() {

33 // in jdk.unsupported

34 Class<?> caller = Reflection.getCallerClass(2);

35

36 // removed

sun_reflect_Reflection.java (https://github.com/JikesRVM/JikesRVM.git) Java · 88 lines

47

48 b.init();

49 b.up(); // skip sun.reflect.Reflection.getCallerClass (this call)

50

51 /* Skip Method.invoke and Constructor.newInstance, (if the caller was called by reflection) */

53 b.up();

54 }

55 /* Work around OpenJDK's work around for Reflection.getCallerClass(..) in java.lang.reflect.Method.invoke(..).

56 * The OpenJDK implementation of getCallerClass assumes a fixed stack depth of 2. The Jikes RVM implementation

57 * is different so we have to work around OpenJDK's work around */

ReflectionTest.java (https://github.com/Byron4j/CookBook.git) Java · 35 lines

29 public void say(){

30 // Exception in thread "main" java.lang.InternalError: CallerSensitive annotation expected at frame 1

31 // at sun.reflect.Reflection.getCallerClass(Native Method)

32 // 改方法只有jdk中的类才能使用

33 System.out.println(Reflection.getCallerClass());

SymbolLookup.java (https://github.com/openjdk/valhalla.git) Java · 82 lines

70 @CallerSensitive

71 static SymbolLookup loaderLookup() {

72 Class<?> caller = Reflection.getCallerClass();

73 Reflection.ensureNativeAccess(caller);

74 ClassLoader loader = Objects.requireNonNull(caller.getClassLoader());

CSM.java (https://github.com/openjdk/valhalla.git) Java · 87 lines

51 @CallerSensitive

52 public static CSM caller() {

53 return caller(Reflection.getCallerClass());

54 }

55

69 @CallerSensitive

70 public static CSM callerNoAlternateImpl() {

71 return new CSM(Reflection.getCallerClass(), false);

72 }

73

74 @CallerSensitive

75 public static CSM caller(Object o1, Object o2, Object o3, Object o4) {

76 return caller(o1, o2, o3, o4, Reflection.getCallerClass());

77 }

78

ClassUtils.java (http://agimatec-tools.googlecode.com/svn/trunk/) Java · 33 lines

16 public static ClassLoader getClassLoader() {

17 final ClassLoader cl = Thread.currentThread().getContextClassLoader();

18 // if Reflection.getCallerClass(3) is not the correct stuff, just drop it.

19 // return cl == null ? Reflection.getCallerClass(3).getClassLoader() : cl;

JDK_sun_reflect_Reflection.go (https://github.com/chaoyangnz/jago.git) Go · 21 lines

2

3 func register_sun_reflect_Reflection() {

4 VM.RegisterNative("sun/reflect/Reflection.getCallerClass()Ljava/lang/Class;", JDK_sun_reflect_Reflection_getCallerClass)

5 VM.RegisterNative("sun/reflect/Reflection.getClassAccessFlags(Ljava/lang/Class;)I", JDK_sun_reflect_Reflection_getClassAccessFlags)

6 }

SpoofedLoginResultJava8.java (https://github.com/lucko/BungeeGuard.git) Java · 49 lines

44 @Override

45 public Property[] getProperties() {

46 Class<?> caller = Reflection.getCallerClass();

47 return getSpoofedProperties(caller);

48 }

App.java (https://github.com/yelanggufeng/tutorials.git) Java · 77 lines

39 StringBuffer sbStack = new StringBuffer();

40 int i = 0;

41 Class<?> caller = Reflection.getCallerClass(i++);

42 do {

43 sbStack.append(i + ".")

44 .append(caller.getName())

45 .append("\n");

46 caller = Reflection.getCallerClass(i++);

47 } while (caller != null);

48 LOGGER.info("2. Call Stack:\n{}", sbStack);

MixedFrames.java (https://github.com/chaoyangnz/maxine.git) Java · 94 lines

80 while (true) {

81 @SuppressWarnings("deprecation")

82 Class callerClass = Reflection.getCallerClass(count);

83 if (callerClass == null) {

84 break;

ScafiAlchemistSupport.scala (https://bitbucket.org/metaphori/experiment-spawn.git) Scala · 42 lines

35 def environment = sense[Environment[Any]]("env")

36

37 import sun.reflect.Reflection.getCallerClass

38 override def aggregate[T](f: => T): T =

39 vm.nest(FunCall[T](vm.index, getCallerClass(PlatformDependentConstants.StackTracePosition).getName()))(true) {

Daemon.java (https://github.com/abhatia/openmrs.git) Java · 171 lines

97

98 // quick check to make sure we're only being called by ourselves

99 Class<?> callerClass = Reflection.getCallerClass(0);

100 if (callerClass.isAssignableFrom(TimerSchedulerTask.class))

101 throw new APIException("This method can only be called from the TimerSchedulerTask class, not "

Reflection_getCallerClass01.java (https://github.com/chaoyangnz/maxine.git) Java · 57 lines

39 @SuppressWarnings("deprecation")

40 static String caller1(int depth) {

41 return Reflection.getCallerClass(depth).getName();

42 }

43 }

GetInfo.java (https://bitbucket.org/Pushpa-R/mpoldauto.git) Java · 23 lines

5 @SuppressWarnings({ "rawtypes", "restriction", "deprecation" })

6 public static final String getCallingClassName(int parentLevel) {

7 // Class CN = sun.reflect.Reflection.getCallerClass(parentLevel);

8 Class CN = sun.reflect.Reflection.getCallerClass(parentLevel);

NetChecker.java (https://github.com/aarondelani/liferay-portal.git) Java · 87 lines

62 int stackIndex = Reflection.getStackIndex(11, 10);

63

64 Class<?> callerClass = Reflection.getCallerClass(stackIndex);

65

66 if (isTrustedCaller(callerClass, permission)) {

74 int stackIndex = Reflection.getStackIndex(11, 10);

75

76 Class<?> callerClass = Reflection.getCallerClass(stackIndex);

77

78 if (isTrustedCaller(callerClass, permission)) {

Logger.java (https://github.com/allesblinkt/Laserschein.git) Java · 171 lines

138

139 public static String callerLocation() {

140 String myString = Reflection.getCallerClass(3).getCanonicalName() + "/" + new Throwable().fillInStackTrace().getStackTrace()[2].getMethodName();

141 //return myString.replaceFirst(STRIP, "");

142 return myString;

DefaultClassLoader.java (git://github.com/DozerMapper/dozer.git) Java · 48 lines

33 Class<?> result = null;

34 try {

35 //Class caller = Reflection.getCallerClass(3); TODO OSGi fix - Move to specific implementation

36 result = ClassUtils.getClass(className);

37 } catch (ClassNotFoundException e) {

JDOMExternalizableStringList.java (https://github.com/rfreedman/intellij-community.git) Java · 97 lines

52 Element listElement = (Element)o;

53 if (ATTR_LIST.equals(listElement.getName())) {

54 final ClassLoader classLoader = Reflection.getCallerClass(2).getClassLoader();

55 for (final Object o1 : listElement.getChildren()) {

56 Element listItemElement = (Element)o1;

ReflectChecker.java (https://github.com/juanferrub/liferay-portal.git) Java · 123 lines

80 int stackIndex = Reflection.getStackIndex(10, 9);

81

82 Class<?> callerClass = Reflection.getCallerClass(stackIndex);

83

84 if (isTrustedCaller(callerClass, permission)) {

101 int stackIndex = Reflection.getStackIndex(11, 10);

102

103 Class<?> callerClass = Reflection.getCallerClass(stackIndex);

104

105 if (isTrustedCaller(callerClass, permission)) {

BasicActionSupport.java (https://github.com/yookien/yookien.git) Java · 206 lines

26 public abstract class BasicActionSupport extends ActionSupport {

27

28 public static Logger logger = Logger.getLogger(sun.reflect.Reflection.getCallerClass(1));

29 public static String CREATE = "create";

30 public static String EDIT = "edit";

OntologyChangeManager.java (https://github.com/dedebf/DetetUbi.git) Java · 179 lines

146 Class cls;

147 int i = 2;

148 cls = sun.reflect.Reflection.getCallerClass(1);

149 while(cls != null){

150 try{

152 return cls.getName();

153 } catch (ClassCastException ex){

154 cls = sun.reflect.Reflection.getCallerClass(i);

155 i++;

156 }

Reflection.java (https://github.com/aarondelani/liferay-portal.git) Java · 126 lines

59 // This operation is faster, so leave it here for legacy versions

60

61 return sun.reflect.Reflection.getCallerClass(depth + 2);

62 }

63

65

66 // [0] Reflection._getCallerClass

67 // [1] Reflection.getCallerClass

68

69 return callerClasses[depth + 1];

Caller.java (https://github.com/GregBowyer/random-junk.git) Java · 52 lines

32

33 public void finalFrame() {

34 //sun.reflect.Reflection.getCallerClass(5);

35 StackTraceElement element = Thread.currentThread().getStackTrace()[5];

36 }

GetCallerClass.java (https://github.com/cccxxxcccxxx/jdk7u-hotspot.git) Java · 105 lines

25 * @test

26 * @bug 8016814 8014925 8021946

27 * @summary Test sun.reflect.Reflection.getCallerClass(int) disabled by default

28 * @compile -XDignore.symbol.file GetCallerClass.java

29 * @run main/othervm GetCallerClass

48 Class<?> c = Test.test();

49 if (!allowed) {

50 throw new RuntimeException("Reflection.getCallerClass should not be allowed");

51 }

52 Class<?> caller = Test.caller();

63 public Class<?> getCallerClass() {

64 // 0: Reflection 1: getCallerClass 2: Test.test 3: main

65 return sun.reflect.Reflection.getCallerClass(3);

66 }

67

Red5LoggerFactory.java (https://github.com/gritchou/Ulysse.git) Java · 84 lines

39 /* TODO: For a future day, the context or application will be determined

40 //get a reference to our caller

41 Class caller = Reflection.getCallerClass(2);

42 //System.err.printf("Caller class: %s classloader: %s\n", caller, caller.getClassLoader());

43

PortalServiceChecker.java (https://github.com/juanferrub/liferay-portal.git) Java · 185 lines

119 int stackIndex = Reflection.getStackIndex(15, 14);

120

121 Class<?> callerClass = Reflection.getCallerClass(stackIndex);

122

123 if (isTrustedCaller(callerClass, permission)) {

124 callerClass = Reflection.getCallerClass(stackIndex + 1);

125

126 if (isTrustedCaller(callerClass, permission)) {

SysTools.java (https://github.com/avega/Advin.git) Java · 117 lines

58 String caller = LOG_EMPTY_PLACER;

59

60 if (Reflection.getCallerClass(3) != null)

61 { caller = Reflection.getCallerClass(3).getSimpleName(); }

62 else if (Reflection.getCallerClass(2) != null)

63 { caller = Reflection.getCallerClass(2).getSimpleName(); }

64 else if (Reflection.getCallerClass(1) != null)

65 { caller = Reflection.getCallerClass(1).getSimpleName(); };

CookieUtil.java (https://github.com/chenchonghz/huikang.git) Java · 109 lines

23

24 public class CookieUtil {

25 public static Logger logger = Logger.getLogger(sun.reflect.Reflection.getCallerClass(1));

26

27 /**

MissingCallerSensitive.java (https://github.com/cccxxxcccxxx/jdk7u-hotspot.git) Java · 73 lines

40 classes.add(Paths.get(testclasses, "MissingCallerSensitive.class"));

41

42 final String method = "sun/reflect/Reflection.getCallerClass";

43 CallerSensitiveFinder csfinder = new CallerSensitiveFinder(method);

44 List<String> errors = csfinder.run(classes);

63 @sun.reflect.CallerSensitive

64 public ClassLoader getCallerLoader() {

65 Class<?> c = sun.reflect.Reflection.getCallerClass();

66 return c.getClassLoader();

67 }

68

69 public ClassLoader missingCallerSensitiveAnnotation() {

70 Class<?> c = sun.reflect.Reflection.getCallerClass();

71 return c.getClassLoader();

72 }

ReflectionGetCallerClassNode.java (https://github.com/dain/graal.git) Java · 105 lines

79 // Cf. JVM_GetCallerClass

80 // NOTE: Start the loop at depth 1 because the current frame state does

81 // not include the Reflection.getCallerClass() frame.

82 for (int n = 1; state != null; state = state.outerFrameState(), n++) {

83 HotSpotResolvedJavaMethod method = (HotSpotResolvedJavaMethod) state.method();

84 switch (n) {

85 case 0:

86 throw GraalInternalError.shouldNotReachHere("current frame state does not include the Reflection.getCallerClass frame");

87 case 1:

88 // Frame 0 and 1 must be caller sensitive (see JVM_GetCallerClass).

SecurityChecker.java (https://github.com/juanferrub/liferay-portal.git) Java · 98 lines

68 new int[] {11, 11}, new int[] {11, 10});

69

70 Class<?> callerClass = Reflection.getCallerClass(stackIndex);

71

72 if (isTrustedCaller(callerClass, permission)) {

83 new int[] {11, 11}, new int[] {11, 10});

84

85 Class<?> callerClass = Reflection.getCallerClass(stackIndex);

86

87 if (isTrustedCaller(callerClass, permission)) {

ReflectionTest.java (https://bitbucket.org/potter/jpf-core) Java · 65 lines

31

32 void foo (){

33 Class<?> callerCls = sun.reflect.Reflection.getCallerClass(0); // that would be getCallerClass()

34 System.out.println("-- getCallerClass(0) = " + callerCls);

35 assertTrue(callerCls.getName().equals("sun.reflect.Reflection"));

36

37 callerCls = sun.reflect.Reflection.getCallerClass(1); // foo()

38 System.out.println("-- getCallerClass(1) = " + callerCls);

39 assertTrue(callerCls.getName().equals("gov.nasa.jpf.test.vm.reflection.ReflectionTest$MyClass"));

40

41 callerCls = sun.reflect.Reflection.getCallerClass(2); // bar()

42 System.out.println("-- getCallerClass(2) = " + callerCls);

43 assertTrue(callerCls.getName().equals("gov.nasa.jpf.test.vm.reflection.ReflectionTest$MyClass"));

8002070-remove_logger_stack_search.patch (https://bitbucket.org/Ringdingcoder/icedtea6) Patch · 153 lines

106 - // calling ClassLoader.

107 - for (int ix = 0; ; ix++) {

108 - Class clz = sun.reflect.Reflection.getCallerClass(ix);

109 - if (clz == null) {

110 - break;

8006611-improve_scripting.patch (https://bitbucket.org/Ringdingcoder/icedtea6) Patch · 79 lines

61 - // But, that method is package private and hence we can't call here.

62 - private ClassLoader getCallerClassLoader() {

63 - Class caller = Reflection.getCallerClass(3);

64 - if (caller == null) {

65 - return null;

Util.scala (https://github.com/stevej/awesome.git) Scala · 51 lines

48 def stackClassnames = stackElements map (_.className) distinct

49 def stackClazzes = stackClassnames flatMap forNameOpt

50 def stackClazzes2 = Stream from 0 map sun.reflect.Reflection.getCallerClass takeWhile (_ != null) toList

51 }

CustomTimingsHandler.java (https://gitlab.com/Glowstone/Glowkit) Java · 76 lines

53 Plugin plugin = null;

54 try {

55 plugin = TimingsManager.getPluginByClassloader(Reflection.getCallerClass(2));

56 } catch (Exception ignored) {}

57

ReflectionTest.java (https://github.com/danbryce/jpf-core2.git) Java · 73 lines

34 // since it is still used by standard libs

35 void foo() {

36 Class<?> callerCls = sun.reflect.Reflection.getCallerClass(0); // that

37 // would

38 // be

41 assertTrue(callerCls.getName().equals("sun.reflect.Reflection"));

42

43 callerCls = sun.reflect.Reflection.getCallerClass(1); // foo()

44 System.out.println("-- getCallerClass(1) = " + callerCls);

45 assertTrue(callerCls.getName().equals(

46 "gov.nasa.jpf.test.vm.reflection.ReflectionTest$MyClass"));

47

48 callerCls = sun.reflect.Reflection.getCallerClass(2); // bar()

49 System.out.println("-- getCallerClass(2) = " + callerCls);

50 assertTrue(callerCls.getName().equals(

PortalServiceChecker.java (https://github.com/greneholt/liferay-portal.git) Java · 186 lines

120 int stackIndex = getStackIndex(15, 14);

121

122 Class<?> callerClass = Reflection.getCallerClass(stackIndex);

123

124 if (isTrustedCaller(callerClass, permission)) {

125 callerClass = Reflection.getCallerClass(stackIndex + 1);

126

127 if (isTrustedCaller(callerClass, permission)) {

8012243-serial_regression.patch (https://bitbucket.org/Ringdingcoder/icedtea6) Patch · 43 lines

13 return null;

14 }

15 - Class<?> caller = Reflection.getCallerClass();

16 - if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(), cl.getClassLoader())) {

17 - ReflectUtil.checkPackageAccess(cl);

18 + if (System.getSecurityManager() != null) {

19 + Class<?> caller = Reflection.getCallerClass();

20 + if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(), cl.getClassLoader())) {

21 + ReflectUtil.checkPackageAccess(cl);

30 @CallerSensitive

31 public Class<?> getType() {

32 - Class<?> caller = Reflection.getCallerClass();

33 - if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(), type.getClassLoader())) {

34 - ReflectUtil.checkPackageAccess(type);

AuthenticationModule.java (https://github.com/benkovsk/whois.git) Java · 122 lines

50 final Credentials offered = update.getCredentials();

51

52 loggerContext.logAuthenticationStrategy(update.getUpdate(), Reflection.getCallerClass().getCanonicalName(), maintainers);

53

54 final List<RpslObject> authenticatedCandidates = Lists.newArrayList();

AccessibleObjectReflectionDelegate.java (https://github.com/amkad/fakereplace.git) Java · 62 lines

55 public static void ensureAccess(AccessibleObject object, int callerStackDepth, Class<?> declaringClass, int modifiers) throws IllegalAccessException {

56 if (!isAccessible(object)) {

57 Class<?> caller = sun.reflect.Reflection.getCallerClass(callerStackDepth);

58 Reflection.ensureMemberAccess(caller, declaringClass, object, modifiers);

59 }

MissingCallerSensitive.java (https://bitbucket.org/screenconnect/openjdk8-jdk) Java · 65 lines

54 @sun.reflect.CallerSensitive

55 public ClassLoader getCallerLoader() {

56 Class<?> c = sun.reflect.Reflection.getCallerClass();

57 return c.getClassLoader();

58 }

59

60 public ClassLoader missingCallerSensitiveAnnotation() {

61 Class<?> c = sun.reflect.Reflection.getCallerClass();

62 return c.getClassLoader();

63 }

8011139-revise_checking_getenclosingclass.patch (https://bitbucket.org/Ringdingcoder/icedtea6) Patch · 59 lines

19 - if (enclosingCandidate != null) {

20 - enclosingCandidate.checkMemberAccess(Member.DECLARED,

21 - Reflection.getCallerClass(), true);

22 - }

23 + if (enclosingCandidate != null)

24 + enclosingCandidate.checkPackageAccess(

25 + ClassLoader.getClassLoader(Reflection.getCallerClass()), true);

26 return enclosingCandidate;

27 }

GetCallerClassTest.sh (https://bitbucket.org/screenconnect/openjdk8-jdk) Shell · 69 lines

24 # @test

25 # @bug 8010117

26 # @summary Test if the VM enforces sun.reflect.Reflection.getCallerClass

27 # be called by methods annotated with sun.reflect.CallerSensitive

28 #

GetCallerClassWithDepth.java (https://bitbucket.org/screenconnect/openjdk8-jdk) Java · 93 lines

25 * @test

26 * @bug 8025799

27 * @summary sun.reflect.Reflection.getCallerClass(int)

28 * @run main GetCallerClassWithDepth

29 */

38

39 try {

40 sun.reflect.Reflection.getCallerClass(-1);

41 throw new RuntimeException("getCallerClass(-1) should fail");

42 } catch (Error e) {

47 public Class<?> getCallerClass() {

48 // 0: Reflection 1: getCallerClass 2: Test.test 3: main

49 return sun.reflect.Reflection.getCallerClass(3);

50 }

51

CallStackUtils.java (https://github.com/gencube/CornerCube.git) Java · 60 lines

17 public static CallerInfo getCallerInfo(int level) {

18 Class caller = cism.getCallerClass(level + 1);

19 //Class caller =sun.reflect.Reflection.getCallerClass(level+1);

20 String clsName = caller.getSimpleName();

21 String pkgName = caller.getCanonicalName().replaceFirst("." + clsName, "");

Game.java (https://github.com/SemenMartynov/SPbAU_Java.git) Java · 82 lines

47 // Window -> Preferences -> Java -> Compiler -> Errors/Warnings ->

48 // Deprecated and restricted API

49 if (sun.reflect.Reflection.getCallerClass(2) != player1.getGameType()) {

50 throw new RuntimeException(

51 "The first player don't know how to play...");

52 }

53 if (sun.reflect.Reflection.getCallerClass(2) != player2.getGameType()) {

54 throw new RuntimeException(

55 "The second player don't know how to play...");

ContainerHolder.java (https://github.com/lmedini/simtole.git) Java · 200 lines

119 reasoner = this.getReasoner();

120 } else

121 throw new ExceptionInInitializerError("Param�tres de l'ontologie non initialis�s ; ontoParamsInit = " + Reflection.getCallerClass(2));

122 }

123

PortalPermissionCollection.java (https://github.com/edgonzales/liferay-portal.git) Java · 97 lines

61 @Override

62 public boolean implies(Permission permission) {

63 if (Reflection.getCallerClass(1) == ProtectionDomain.class) {

64 return false;

65 }

8008132-better_serialization.patch (https://bitbucket.org/Ringdingcoder/icedtea6) Patch · 122 lines

106 + // as follows:

107 + //

108 + // 0: Reflection.getCallerClass

109 + // 1: getCallerClassLoader()

110 + // 2: ObjectStreamField.getType() or ObjectStreamClass.forClass()

113 + // NOTE: copied from java.lang.ClassLoader and modified.

114 + static ClassLoader getCallerClassLoader() {

115 + Class caller = Reflection.getCallerClass(3);

116 + return caller.getClassLoader();

117 + }

LoggerUtil.java (https://github.com/mung3r/ecoCreature.git) Java · 100 lines

88 if (debug) {

89 @SuppressWarnings("restriction")

90 Class<?> aClass = sun.reflect.Reflection.getCallerClass(2);

91

92 logger.info(format(aClass.getSimpleName() + ": " + msg));

sun_reflect_Reflection.java (https://github.com/joekoolade/JEI.git) Java · 104 lines

53 // b.up();

54 // }

55 b.up(); // skip sun.reflect.Reflection.getCallerClass (this call)

56 b.up();

57 /*

64 }

65 /*

66 * Work around OpenJDK's work around for Reflection.getCallerClass(..) in

67 * java.lang.reflect.Method.invoke(..). The OpenJDK implementation of

68 * getCallerClass assumes a fixed stack depth of 2. The Jikes RVM implementation

LoggerManager.java (https://github.com/cryptoyoshi/vooga.git) Java · 313 lines

45 */

46 public LoggerManager () {

47 initializeLogger(LoggerReflection.getCallerClassName());

48 }

49

252 public void log (Level level, String message) {

253 LogRecord record = new LogRecord(level, message);

254 record.setSourceClassName(LoggerReflection.getCallerClassName());

255 record.setSourceMethodName(LoggerReflection.getCallerMethodName());

256 myLogger.log(record);

TextureManager.java (https://github.com/ClemensB/mod_redstoneExtended.git) Java · 72 lines

38 String prefix;

39

40 Class callerClass = Reflection.getCallerClass(2);

41 if (callerClass.getSimpleName().equals("TextureManager"))

42 callerClass = Reflection.getCallerClass(3);

LoggerUtil.java (https://github.com/david3424/rain.git) Java · 389 lines

37 */

38 private static Class<?> getCallerClass() {

39 return Reflection.getCallerClass(3);

40 }

41