Class ReferenceNode

    • Field Detail

      • THIS_PACKAGE

        private static final java.lang.String THIS_PACKAGE
      • CLASS_GET_MODULE_METHOD

        private static final java.lang.reflect.Method CLASS_GET_MODULE_METHOD
      • MODULE_IS_EXPORTED_METHOD

        private static final java.lang.reflect.Method MODULE_IS_EXPORTED_METHOD
    • Constructor Detail

      • ReferenceNode

        ReferenceNode​(java.lang.String resourceName,
                      int lineNumber)
    • Method Detail

      • invokeMethod

        java.lang.Object invokeMethod​(java.lang.reflect.Method method,
                                      java.lang.Object target,
                                      java.util.List<java.lang.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 java.lang.String packageNameOf​(java.lang.Class<?> c)
      • visibleMethod

        static java.lang.reflect.Method visibleMethod​(java.lang.reflect.Method method,
                                                      java.lang.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​(java.lang.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​(java.lang.Class<?> c)