Browse Source

Some code comments to fill in gaps.

tags/rel_3_23_0_ga
nickl- 6 years ago
parent
commit
df58ae940d
1 changed files with 30 additions and 0 deletions
  1. 30
    0
      src/main/javassist/util/proxy/SecurityActions.java

+ 30
- 0
src/main/javassist/util/proxy/SecurityActions.java View File

@@ -36,6 +36,18 @@ import javassist.bytecode.ClassFile;
class SecurityActions extends SecurityManager
{
public static final SecurityActions stack = new SecurityActions();
/**
* Since Java 9 abruptly removed <code>Reflection.getCallerClass()</code>
* in favour of <code>StackWalker</code> we are left having to find a
* solution for the older versions without upsetting the new compiler.
*
* The member scoped function <code>getClassContext()</code>
* available as a <code>SecurityManager</code> sibling remains
* functional across all versions, for now.
*
* @return represents the declaring class of the method that invoked
* the method that called this or idx 2 on the stack trace.
* @since 3.23 */
public Class<?> getCallerClass()
{
return getClassContext()[2];
@@ -207,6 +219,18 @@ class SecurityActions extends SecurityManager
throw new RuntimeException(e.getCause());
}
}
/**
* _The_ Notorious sun.misc.Unsafe in all its glory, but anonymous
* so as not to attract unwanted attention. Kept in two separate
* parts it manages to avoid detection from linker/compiler/general
* complainers and those. This functionality will vanish from the
* JDK soon but in the meantime it shouldn't be an obstacle.
*
* All exposed methods are cached in a dictionary with overloaded
* methods collected under their corresponding keys. Currently the
* implementation assumes there is only one, if you need find a
* need there will have to be a compare.
* @since 3.23 */
class TheUnsafe
{
final Class<?> unsafe;
@@ -243,6 +267,12 @@ class SecurityActions extends SecurityManager
return null;
}
}
/**
* Java 9 now complains about every privileged action regardless.
* Displaying warnings of "illegal usage" and then instructing users
* to go hassle the maintainers in order to have it fixed.
* Making it hush for now, see all fixed.
* @param tu theUnsafe that'll fix it */
static void disableWarning(TheUnsafe tu) {
try {
if (ClassFile.MAJOR_VERSION < ClassFile.JAVA_9)

Loading…
Cancel
Save