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
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
AtomicIntegerFieldUpdater.java (https://github.com/zxiaofan/JDK.git) Java · 318 lines
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
SecurityChecker.java (https://github.com/lululiferay/liferay-portal.git) Java · 207 lines
59 protected boolean hasGetPolicy() {
60 Class<?> callerClass8 = Reflection.getCallerClass(8);
62 if (isGlassfishJ2EEInstanceListener(
80 protected boolean hasSetPolicy() {
81 Class<?> callerClass6 = Reflection.getCallerClass(6);
83 if (isGlassfishPolicyContextHandlerImpl(callerClass6)) {
87 }
89 Class<?> callerClass7 = Reflection.getCallerClass(7);
91 if (isGeronimoDispatchListener(callerClass7)) {
ReflectionComparison.java (https://gitlab.com/essere.lab.public/qualitas.class-corpus) Java · 130 lines
JDOMExternalizableStringList.java (https://github.com/maartenh/intellij-community.git) Java · 100 lines
Reflect.scala (https://github.com/migue/akka.git) Scala · 136 lines
ReflectChecker.java (git://github.com/liferay/liferay-portal.git) Java · 123 lines
80 int stackIndex = Reflection.getStackIndex(3, 2);
82 Class<?> callerClass = Reflection.getCallerClass(stackIndex);
84 if (isTrustedCaller(callerClass, permission)) {
101 int stackIndex = Reflection.getStackIndex(4, 3);
103 Class<?> callerClass = Reflection.getCallerClass(stackIndex);
105 if (isTrustedCaller(callerClass, permission)) {
GetCallerClassTests.java (https://github.com/eclipse/openj9.git) Java · 254 lines
41 try {
42 sun.reflect.Reflection.getCallerClass();
43 System.out.println(TESTCASE_NAME + ": FAILED 1");
44 return false;
62 try {
63 sun.reflect.Reflection.getCallerClass();
64 System.out.println(TESTCASE_NAME + ": FAILED 1");
65 return false;
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
41 try {
42 jdk.internal.reflect.Reflection.getCallerClass();
43 System.out.println(TESTCASE_NAME + ": FAILED 1");
44 return false;
62 try {
63 jdk.internal.reflect.Reflection.getCallerClass();
64 System.out.println(TESTCASE_NAME + ": FAILED 1");
65 return false;
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
SecurityChecker.java (https://github.com/christine-huang/liferay-portal.git) Java · 95 lines
66 int stackIndex = getStackIndex(11, 11, 10);
68 Class<?> callerClass = Reflection.getCallerClass(stackIndex);
70 if (isTrustedCaller(callerClass, permission)) {
80 int stackIndex = getStackIndex(11, 11, 10);
82 Class<?> callerClass = Reflection.getCallerClass(stackIndex);
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.
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.
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
LogUtil.java (https://github.com/nothize/suite.git) Java · 84 lines
ClassLoaderUtils.java (https://github.com/naver/pinpoint.git) Java · 118 lines
FileLoader.java (https://github.com/Oshan96/CustomStage.git) Java · 191 lines
PortalServiceChecker.java (git://github.com/liferay/liferay-portal.git) Java · 184 lines
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);
63 Class<?> callerClass = Reflection.getCallerClass(stackIndex);
65 if (isTrustedCaller(callerClass, permission)) {
73 int stackIndex = getStackIndex(11, 10);
75 Class<?> callerClass = Reflection.getCallerClass(stackIndex);
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
UIDefaultsLookup.java (git://pkgs.fedoraproject.org/jide-oss) Java · 415 lines
UnsafeSupport.java (https://github.com/yangjiandong/sshapp.git) Java · 79 lines
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 }
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
MissingCallerSensitive.java (https://github.com/openjdk/jdk.git) Java · 71 lines
ReflectChecker.java (https://github.com/christine-huang/liferay-portal.git) Java · 48 lines
NetChecker.java (git://github.com/liferay/liferay-portal.git) Java · 87 lines
62 int stackIndex = Reflection.getStackIndex(4, 3);
64 Class<?> callerClass = Reflection.getCallerClass(stackIndex);
66 if (isTrustedCaller(callerClass, permission)) {
74 int stackIndex = Reflection.getStackIndex(4, 3);
76 Class<?> callerClass = Reflection.getCallerClass(stackIndex);
78 if (isTrustedCaller(callerClass, permission)) {
CheckerUtil.java (https://github.com/lululiferay/liferay-portal.git) Java · 54 lines
SerialJavaObject.java (https://github.com/zxiaofan/JDK.git) Java · 173 lines
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 }
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
CallerSensitive.java (https://github.com/openjdk/jdk.git) Java · 41 lines
CSM.java (https://github.com/openjdk/jdk.git) Java · 77 lines
Reflection.java (git://github.com/liferay/liferay-portal.git) Java · 126 lines
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
59 return sun.reflect.Reflection.getCallerClass(depth + 2);
60 }
64 // [0] Reflection._getCallerClass
65 // [1] Reflection.getCallerClass
67 return callerClasses[depth + 1];
DataManagerPlugin.java (https://github.com/CovertJaguar/Railcraft.git) Java · 166 lines
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)
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
LoggerFactory.java (https://github.com/DanielLukic/idea-simple-syntax.git) Java · 36 lines
Unsafe.java (https://github.com/google/desugar_jdk_libs.git) Java · 835 lines
CallerSensitiveClass.java (https://github.com/eclipse/openj9.git) Java · 32 lines
CallerSensitiveAdapter.java (https://github.com/openjdk/valhalla.git) Java · 112 lines
TestGetCallerClassName.java (https://github.com/happyyangyuan/xian.git) Java · 120 lines
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 }
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
Main.java (https://github.com/openjdk/jdk.git) Java · 49 lines
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
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
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 }
SecurityChecker.java (git://github.com/liferay/liferay-portal.git) Java · 99 lines
68 new int[] {4, 4}, new int[] {4, 3});
70 Class<?> callerClass = Reflection.getCallerClass(stackIndex);
72 if (isTrustedCaller(callerClass, permission)) {
83 new int[] {4, 4}, new int[] {4, 3});
85 Class<?> callerClass = Reflection.getCallerClass(stackIndex);
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"));
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"));
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 */
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 }
ReflectionTest.java (https://github.com/CovertJaguar/Railcraft.git) Java · 25 lines
GetCallerClass.java (https://github.com/openjdk/valhalla.git) Java · 91 lines
34 public Class<?> missingCallerSensitiveAnnotation() {
35 return jdk.internal.reflect.Reflection.getCallerClass();
36 }
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
sun_reflect_Reflection.java (https://github.com/JikesRVM/JikesRVM.git) Java · 88 lines
48 b.init();
49 b.up(); // skip sun.reflect.Reflection.getCallerClass (this call)
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
SymbolLookup.java (https://github.com/openjdk/valhalla.git) Java · 82 lines
CSM.java (https://github.com/openjdk/valhalla.git) Java · 87 lines
51 @CallerSensitive
52 public static CSM caller() {
53 return caller(Reflection.getCallerClass());
54 }
69 @CallerSensitive
70 public static CSM callerNoAlternateImpl() {
71 return new CSM(Reflection.getCallerClass(), false);
72 }
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 }
ClassUtils.java (http://agimatec-tools.googlecode.com/svn/trunk/) Java · 33 lines
JDK_sun_reflect_Reflection.go (https://github.com/chaoyangnz/jago.git) Go · 21 lines
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
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
ScafiAlchemistSupport.scala (https://bitbucket.org/metaphori/experiment-spawn.git) Scala · 42 lines
Daemon.java (https://github.com/abhatia/openmrs.git) Java · 171 lines
Reflection_getCallerClass01.java (https://github.com/chaoyangnz/maxine.git) Java · 57 lines
GetInfo.java (https://bitbucket.org/Pushpa-R/mpoldauto.git) Java · 23 lines
NetChecker.java (https://github.com/aarondelani/liferay-portal.git) Java · 87 lines
62 int stackIndex = Reflection.getStackIndex(11, 10);
64 Class<?> callerClass = Reflection.getCallerClass(stackIndex);
66 if (isTrustedCaller(callerClass, permission)) {
74 int stackIndex = Reflection.getStackIndex(11, 10);
76 Class<?> callerClass = Reflection.getCallerClass(stackIndex);
78 if (isTrustedCaller(callerClass, permission)) {
Logger.java (https://github.com/allesblinkt/Laserschein.git) Java · 171 lines
DefaultClassLoader.java (git://github.com/DozerMapper/dozer.git) Java · 48 lines
JDOMExternalizableStringList.java (https://github.com/rfreedman/intellij-community.git) Java · 97 lines
ReflectChecker.java (https://github.com/juanferrub/liferay-portal.git) Java · 123 lines
80 int stackIndex = Reflection.getStackIndex(10, 9);
82 Class<?> callerClass = Reflection.getCallerClass(stackIndex);
84 if (isTrustedCaller(callerClass, permission)) {
101 int stackIndex = Reflection.getStackIndex(11, 10);
103 Class<?> callerClass = Reflection.getCallerClass(stackIndex);
105 if (isTrustedCaller(callerClass, permission)) {
BasicActionSupport.java (https://github.com/yookien/yookien.git) Java · 206 lines
OntologyChangeManager.java (https://github.com/dedebf/DetetUbi.git) Java · 179 lines
Reflection.java (https://github.com/aarondelani/liferay-portal.git) Java · 126 lines
Caller.java (https://github.com/GregBowyer/random-junk.git) Java · 52 lines
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 }
Red5LoggerFactory.java (https://github.com/gritchou/Ulysse.git) Java · 84 lines
PortalServiceChecker.java (https://github.com/juanferrub/liferay-portal.git) Java · 185 lines
SysTools.java (https://github.com/avega/Advin.git) Java · 117 lines
58 String caller = LOG_EMPTY_PLACER;
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
MissingCallerSensitive.java (https://github.com/cccxxxcccxxx/jdk7u-hotspot.git) Java · 73 lines
40 classes.add(Paths.get(testclasses, "MissingCallerSensitive.class"));
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 }
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});
70 Class<?> callerClass = Reflection.getCallerClass(stackIndex);
72 if (isTrustedCaller(callerClass, permission)) {
83 new int[] {11, 11}, new int[] {11, 10});
85 Class<?> callerClass = Reflection.getCallerClass(stackIndex);
87 if (isTrustedCaller(callerClass, permission)) {
ReflectionTest.java (https://bitbucket.org/potter/jpf-core) Java · 65 lines
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"));
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"));
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
8006611-improve_scripting.patch (https://bitbucket.org/Ringdingcoder/icedtea6) Patch · 79 lines
Util.scala (https://github.com/stevej/awesome.git) Scala · 51 lines
CustomTimingsHandler.java (https://gitlab.com/Glowstone/Glowkit) Java · 76 lines
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"));
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"));
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
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
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 }
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
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 */
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 }
CallStackUtils.java (https://github.com/gencube/CornerCube.git) Java · 60 lines
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
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
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 }
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);