Class HolderAccessors


  • public final class HolderAccessors
    extends java.lang.Object
    Read access to game values kept in constant-dynamic String[] holders.

    Some builds store a credential in a one-element array produced by a ConstantBootstraps.invoke bootstrap and written by a static setter of the exact shape ldc condy; iconst_0; aload_0; aastore; return. The array exists only in the owner class's resolved constant pool: nothing outside that class can load it, and there is no native getter to call.

    This emits one public static getter next to the setter, loading the same constant, so it returns the very array the game reads and writes. The getter is marked synthetic and named after its setter.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String GETTER_SUFFIX  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.objectweb.asm.tree.MethodNode ensureGetter​(org.objectweb.asm.tree.ClassNode owner, java.lang.String setterName)
      Add the getter for owner.setterName, or return the existing one.
      static java.lang.String getterName​(java.lang.String setterName)  
      static org.objectweb.asm.ConstantDynamic holder​(org.objectweb.asm.tree.MethodNode method)
      The constant written by a holder setter, or null if the method is not exactly ldc condy String[]; iconst_0; aload_0; aastore; return.
      static void requireDistinctDynamics​(byte[] original, java.lang.String className)
      Refuse to rewrite a class whose constant pool holds two value-equal mutable (array) dynamic constants.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getterName

        public static java.lang.String getterName​(java.lang.String setterName)
      • ensureGetter

        public static org.objectweb.asm.tree.MethodNode ensureGetter​(org.objectweb.asm.tree.ClassNode owner,
                                                                     java.lang.String setterName)
        Add the getter for owner.setterName, or return the existing one.
        Throws:
        java.lang.IllegalStateException - if the setter does not have the exact holder shape
      • holder

        public static org.objectweb.asm.ConstantDynamic holder​(org.objectweb.asm.tree.MethodNode method)
        The constant written by a holder setter, or null if the method is not exactly ldc condy String[]; iconst_0; aload_0; aastore; return.
      • requireDistinctDynamics

        public static void requireDistinctDynamics​(byte[] original,
                                                   java.lang.String className)
        Refuse to rewrite a class whose constant pool holds two value-equal mutable (array) dynamic constants.

        ASM rebuilds the pool from the tree and merges equal constants. Two distinct holders that happened to share a bootstrap would then collapse into one array, silently aliasing credentials. Every current holder has its own factory method, so this never fires today; it exists so that a future build which changes that fails loudly instead of logging someone in wrong.