Get the template class of this template. Not to be used in user application or template

@param useCaller
@return a <code>TemplateClass</code>
543850
public TemplateClass __getTemplateClass(boolean useCaller) {
        TemplateClass tc = __templateClass;
        if (useCaller && null == tc) {
            TemplateBase caller = __caller();
            if (null != caller) return caller.__getTemplateClass(true);
        }
        return tc;
    }
788255
@PerformanceSensitive
    public Class<?> getCallerClass(final String fqcn, final String pkg) {
        boolean next = false;
        Class<?> clazz;
        for (int i = 2; null != (clazz = getCallerClass(i)); i++) {
            if (fqcn.equals(clazz.getName())) {
                next = true;
                continue;
            }
            if (next && clazz.getName().startsWith(pkg)) {
                return clazz;
            }
        }
        // TODO: return Object.class
        return null;
    }
873418
@Nullable
  public static Class <?> getPrimitiveWrapperClass (@Nullable final Class <?> aClass)
  {
    if (isPrimitiveWrapperType (aClass))
      return aClass;
    return PRIMITIVE_TO_WRAPPER.get (aClass);
  }
186837
public FunctionInfo getFunction(String methodDesc) {

        methodDesc = methodDesc.replace('.', '$');
        int paramsStartPos = methodDesc.indexOf('(');
        int firstSep = methodDesc.indexOf('$');
        String prefix = firstSep != -1 && firstSep < paramsStartPos ? methodDesc.substring(0, firstSep) : "";
        methodDesc = prefix.length() > 0 ? methodDesc.substring(prefix.length() + 1) : methodDesc;
        FunctionInfo[] f = getFunctions();

        for (int i = 0; i < f.length; i++) {
            String p = f[i].getProvider() != null ? f[i].getProvider().getContextPrefixName().trim() : "";
            p = p.endsWith("$") ? p.substring(0, p.length() - 1) : p;
            if (("".equals(prefix) || prefix.equals(p)) &&
                    new TemplateCallExtractor.AppMethodInfo(f[i].getDescriptor().getMethod()).equals(
                    new TemplateCallExtractor.AppMethodInfo(methodDesc)))
            return f[i];
        }

        return null;

    }
140224
@Singleton
    public TemplateEngine templateEngine(ITemplateResolver templateResolver,
            IEngineContextFactory engineContextFactory, ILinkBuilder linkBuilder) {
        TemplateEngine engine = new TemplateEngine();
        engine.setEngineContextFactory(engineContextFactory);
        engine.setLinkBuilder(linkBuilder);
        engine.setTemplateResolver(templateResolver);
        return engine;
    }
37980
public Class<? extends AbstractInvokable> getInvokableClass(ClassLoader cl) {
		if (cl == null) {
			throw new NullPointerException("The classloader must not be null.");
		}
		if (invokableClassName == null) {
			return null;
		}

		try {
			return Class.forName(invokableClassName, true, cl).asSubclass(AbstractInvokable.class);
		}
		catch (ClassNotFoundException e) {
			throw new RuntimeException("The user-code class could not be resolved.", e);
		}
		catch (ClassCastException e) {
			throw new RuntimeException("The user-code class is no subclass of " + AbstractInvokable.class.getName(), e);
		}
	}
239301
@PerformanceSensitive
    public Class<?> getCallerClass(final int depth) {
        if (depth < 0) {
            throw new IndexOutOfBoundsException(Integer.toString(depth));
        }
        // note that we need to add 1 to the depth value to compensate for this method, but not for the Method.invoke
        // since Reflection.getCallerClass ignores the call to Method.invoke()
        try {
            return (Class<?>) GET_CALLER_CLASS.invoke(null, depth + 1 + JDK_7u25_OFFSET);
        } catch (final Exception e) {
            // theoretically this could happen if the caller class were native code
            // TODO: return Object.class
            return null;
        }
    }
460555
public static Class<?> getExceptionCallerClass(final Throwable t) {
		final StackTraceElement[] stackTrace = t.getStackTrace();
		for (final StackTraceElement stackTraceElement : stackTrace) {
			logger.debug(stackTraceElement.getClassName().concat(".").concat(stackTraceElement.getMethodName()));
		}
		return null;
	}
130186
public Class<? extends org.eclipse.xtext.parser.antlr.ITokenDefProvider> bindITokenDefProvider() {
		return org.eclipse.xtext.parser.antlr.AntlrTokenDefProvider.class;
	}
998661
public static String getCaller() {
        StackTraceElement[] stacks = Thread.currentThread().getStackTrace();
        if (stacks != null) {
            for (int i = 0; i < stacks.length; i++) {
                String cn = stacks[i].getClassName();
                if (cn != null && !Constants.CLASSNAME_TO_ESCAPE.contains(cn)) {
                    return cn;
                }
            }
        }
        return null;
    }
614722
public static AppMethodInfo[] getAppMethodsCalled(String basePath, final String templateName,
            final String contextClass) {

        final HashMap<AppMethodInfo, AppMethodInfo> methodsCalledMap =
            new HashMap<AppMethodInfo, AppMethodInfo>();

        try {
            File templatePath = new File(new File(basePath),
                templateName.replace('.', '/') + ".class");
            if (!templatePath.exists() &&
                    templateName.startsWith(TEMPLATE_PACKAGE)) {
                templatePath = new File(new File(basePath),
                    templateName.substring(TEMPLATE_PACKAGE.length()).
                    replace('.','/') + ".class");
            }

            final MethodInfo executeMethod = getTemplateExecuteMethod(new FileInputStream(templatePath));

            CodeDisassembler cd = new CodeDisassembler(executeMethod);
            cd.disassemble(new CodeAssemblerPrinter(executeMethod
                .getMethodDescriptor().getParameterTypes(), true, null) {

                 public void invokeVirtual(String className, String methodName,
                         TypeDesc ret, TypeDesc[] params)  {
                     if ("print".equals(methodName) ||
                             "toString".equals(methodName) ||
                             "equals".equals(methodName) ||
                             (contextClass.indexOf(className) == -1 &&
                             className.indexOf("MergedClass") == -1))
                         return;

                     AppMethodInfo ami = new AppMethodInfo(methodName, params);
                     if (! methodsCalledMap.containsKey(ami))
                         methodsCalledMap.put(ami, ami);
                     else
                         methodsCalledMap.get(ami).incCallCount();
                 }

                 public void println(String s) { } // Do nothing
            });

            final MethodInfo substituteMethod = getTemplateSubstituteMethod(new FileInputStream(templatePath));

            if (substituteMethod == null)
                return methodsCalledMap.values().toArray(
                    new AppMethodInfo[methodsCalledMap.values().size()]);

            // check the substitute methods on this template
            cd = new CodeDisassembler(substituteMethod);
            cd.disassemble(new CodeAssemblerPrinter(substituteMethod
                .getMethodDescriptor().getParameterTypes(), true, null) {

                 public void invokeVirtual(String className, String methodName,
                         TypeDesc ret, TypeDesc[] params)  {
                     if ("print".equals(methodName) ||
                             "toString".equals(methodName) ||
                             "equals".equals(methodName) ||
                             (contextClass.indexOf(className) == -1 &&
                             className.indexOf("MergedClass") == -1))
                         return;

                     AppMethodInfo ami = new AppMethodInfo(methodName, params);
                     if (! methodsCalledMap.containsKey(ami))
                         methodsCalledMap.put(ami, ami);
                     else
                         methodsCalledMap.get(ami).incCallCount();
                 }

                 public void println(String s) { } // Do nothing
            });
        }
        catch (IOException ix) {
            return new AppMethodInfo[0];
        }

        return methodsCalledMap.values().toArray(
            new AppMethodInfo[methodsCalledMap.values().size()]);
    }
359537
public final static Class<?> getCompiledClass(String className, boolean useCache) throws CompilationException, ClassLoadException {
        try {
            if (! useCache) {
                
                /*String compilationResult = compileClass(className);
                System.out.println("************ compilationResult   " + compilationResult);
                if (compilationResult.contains("cannot read")) {
                    throw new ClassLoadException(compilationResult);
                }
                if (compilationResult.contains("error")) {
                    throw new CompilationException(compilationResult);
                }*/

                DynamicClassLoader dynamicClassLoader = new DynamicClassLoader(DynamicClassFactory.class.getClassLoader());
                return dynamicClassLoader.loadClass(className);
            } else {
                return CACHED_CONTROLLERS.computeIfAbsent(className, WRAP_FORNAME);
            }
        } catch (CompilationException e) {
            throw e; // so the exception doesn't get caught by the more general catch(Exception)
        } catch (Exception e) {
            throw new ClassLoadException(e);
        }
    }
39370
protected Template load(Class<?> pageClass, Show methodShow) {
    //
    // try to find the template name
    //
    String template = null;
    String extension = null;

    Show show = pageClass.getAnnotation(Show.class);
    if (null != show) {
      template = show.value();
    }
    
    if (methodShow != null) {
        if (template != null) {
            template = template + methodShow.value();
        }
        else {
            template = methodShow.value();
        }
    }

    //
    // an empty string means no template name was given
    //
    if (template == null || template.length() == 0) {
      // use the default name for the page class
      template = pageClass.getSimpleName();
    } else {
      // Check and see if the supplied template value has a supported file extension
      for (String ext : templateSystem.getTemplateExtensions()) {
        String type = ext.replace("%s.", ".");
        if (template.endsWith(type)) {
          extension = type;
          break;
        }
      }
    }

    if (null == template) {
      throw new MissingTemplateException(String.format("Could not determine the base template name for %s", Show.class));
    }

    TemplateSource templateSource = null;
    String text;

    boolean appendExtension = false;
    try {
      final ServletContext servletContext = context.get();
      InputStream stream = null;

      //
      // If there was a matching file extension, short-circuit the deep search
      //

      if (template.contains(".") || null != extension) {
        // Check class neighborhood for direct match
        stream = pageClass.getResourceAsStream(template);

        // Check url conventions for direct match
        if (null == stream) {
          stream = open(template, servletContext);
        }

        // Same as above, but checks in WEB-INF
        if (null == stream) {
          stream = openWebInf(template, servletContext);
        }

        // Finally, try to get the resource from the servlet context internally
        if (null == stream) {
          stream = servletContext.getResourceAsStream(template);
        }
      }

      //
      // No direct match, so start hunting.
      // First, look in class neighborhood for template
      //

      if (null == stream) {
        appendExtension = true;
        for (String ext : templateSystem.getTemplateExtensions()) {
          String name = String.format(ext, template);

          stream = pageClass.getResourceAsStream(name);

          if (null != stream) {
            extension = ext;
            break;
          }
        }
      }

      //
      // Check for qualified file paths in context
      // TODO: I think this is redundant, but make sure before deleting
      //

      if (null == stream) {
        for (String ext : templateSystem.getTemplateExtensions()) {
          String name = String.format(ext, pageClass.getSimpleName());

          stream = open(name, servletContext);

          if (null != stream) {
            extension = ext;
            break;
          }
        }
      }

      //
      // Same thing, but check in WEB-INF
      //

      if (null == stream) {
        for (String ext : templateSystem.getTemplateExtensions()) {
          String name = String.format(ext, pageClass.getSimpleName());

          stream = openWebInf(name, servletContext);

          if (null != stream) {
            extension = ext;
            break;
          }
        }
      }

      //
      // Finally, look in the ServletContext resource path if not in classpath
      //

      if (null == stream) {
        for (String ext : templateSystem.getTemplateExtensions()) {
          String name = String.format(ext, template);

          stream = servletContext.getResourceAsStream(name);

          if (null != stream) {
            extension = ext;
            break;
          }
        }
      }

      //
      //if there's still no template, then error out
      //
      if (null == stream) {
        throw new MissingTemplateException(String.format(
          "Could not find a suitable template for %s, did you remember to place an @Show? None of " +
          Arrays.toString(templateSystem.getTemplateExtensions()).replace("%s.", ".")
          + " could be found in either package [%s], in the root of the resource dir OR in WEB-INF/.",
          pageClass.getName(), pageClass.getSimpleName(), pageClass.getPackage().getName()));
      }

      text = read(stream);
    } catch (IOException e) {
      throw new TemplateLoadingException("Could not load template for (i/o error): " + pageClass, e);
    }

    if (appendExtension)
      template += "." + extension;

    return new Template(template, text, templateSource);
    
  }
1253888
public Class<? extends ElementBase> getRootClass() {
        LayoutElement top = root == null ? null : root.getChild(LayoutElement.class);
        return top == null ? null : top.getDefinition().getClazz();
    }
1342349
public static Class<?>[] getActualClass(Type genericType) {

        if (genericType instanceof ParameterizedType) {

            Type[] actualTypes = ((ParameterizedType) genericType).getActualTypeArguments();
            Class<?>[] actualClasses = new Class<?>[actualTypes.length];

            int i = 0;
            while (i < actualTypes.length) {
                Type actualType = actualTypes[i];
                if (actualType instanceof Class<?>) {
                    actualClasses[i] = (Class<?>) actualType;
                } else if (actualType instanceof GenericArrayType) {
                    Type componentType = ((GenericArrayType) actualType).getGenericComponentType();
                    actualClasses[i] = Array.newInstance((Class<?>) componentType, 0).getClass();
                }
                i++;
            }

            return actualClasses;
        }

        return EMPTY_CLASSES;
    }
1032701
public static final TreeRenderer getInstance(String className)
    {
        TreeRenderer renderer = null;
        if (className != null) {
            className = className.trim();

            // create an instance of the def template formatter class
            ClassLoader cl = DiscoveryUtils.getClassLoader();
            try {
                Class rendererClass = cl.loadClass(className);
                if (!TreeRenderer.class.isAssignableFrom(rendererClass)) {
                    _log.error("The tree renderer class, " + className
                            + ", does not extend TreeRenderer.");
                }
                else {
                    renderer = (TreeRenderer) rendererClass.newInstance();
                }
            }
            catch ( ClassNotFoundException e ) {
                _log.error( "Could not find TreeRenderer class " + className, e );
            }
            catch (InstantiationException e) {
                _log.error( "Could not instantiate TreeRenderer class " + className, e );
            }
            catch (IllegalAccessException e) {
                _log.error( "Could not instantiate TreeRenderer class " + className, e );
            }
        }
        return renderer;
    }
569963
@Override
  public ClassLoader getClassLoader() {

    // To follow the same behavior of Class.forName(...) I had to play
    // dirty (Supported by Sun, IBM & BEA JVMs)
    try {
      // Get a reference to this class' class-loader
      ClassLoader cl = this.getClass().getClassLoader();
      // Create a method instance representing the protected
      // getCallerClassLoader method of class ClassLoader
      Method mthd = ClassLoader.class.getDeclaredMethod("getCallerClassLoader", new Class[0]);
      // Make the method accessible.
      AccessibleObject.setAccessible(new AccessibleObject[] {mthd}, true);
      // Try to get the caller's class-loader
      return (ClassLoader) mthd.invoke(cl, new Object[0]);
    } catch (Exception all) {
      // Use this class' class-loader
      return this.getClass().getClassLoader();
    }
  }