Class ReferenceNode

Direct Known Subclasses:
ReferenceNode.IndexReferenceNode, ReferenceNode.MemberReferenceNode, ReferenceNode.MethodReferenceNode, ReferenceNode.PlainReferenceNode

abstract class ReferenceNode extends ExpressionNode
A node in the parse tree that is a reference. A reference is anything beginning with $, such as $x or $x[$i].foo($j).
  • Field Details

    • THIS_PACKAGE

      private static final String THIS_PACKAGE
    • CLASS_GET_MODULE_METHOD

      private static final Method CLASS_GET_MODULE_METHOD
    • MODULE_IS_EXPORTED_METHOD

      private static final Method MODULE_IS_EXPORTED_METHOD
  • Constructor Details

    • ReferenceNode

      ReferenceNode(String resourceName, int lineNumber)
  • Method Details

    • invokeMethod

      Object invokeMethod(Method method, Object target, List<Object> argValues)
      Invoke the given method on the given target with the given arguments. The method is expected to be public, but the class it is in might not be. In that case we will search up the hierarchy for an ancestor that is public and has the same method, and use that to invoke the method. Otherwise we would get an IllegalAccessException. More than one ancestor might define the method, but it doesn't matter which one we invoke since ultimately the code that will run will be the same.
    • packageNameOf

      private static String packageNameOf(Class<?> c)
    • visibleMethod

      static Method visibleMethod(Method method, Class<?> in)
      Returns a Method with the same name and parameter types as the given one, but that is in a public class or interface. This might be the given method, or it might be a method in a superclass or superinterface.
      Returns:
      a public method in a public class or interface, or null if none was found.
    • classIsPublic

      private static boolean classIsPublic(Class<?> c)
      Returns whether the given class is public as seen from this class. Prior to Java 9, a class was either public or not public. But with the introduction of modules in Java 9, a class can be marked public and yet not be visible, if it is not exported from the module it appears in. So, on Java 9, we perform an additional check on class c, which is effectively c.getModule().isExported(c.getPackageName()). We use reflection so that the code can compile on earlier Java versions.
    • classIsExported

      private static boolean classIsExported(Class<?> c)