private static Class<?> loadClass(String className) {
   try {
     ClassLoader cl = Thread.currentThread().getContextClassLoader();
     return cl.loadClass(className.replace('/', '.'));
   } catch (ClassNotFoundException e) {
     throw new RuntimeException(e);
   }
 }
Пример #2
0
    private static void checkAccess() {
      StackTraceElement[] cause = Thread.currentThread().getStackTrace();

      String callingClass = cause.length > 2 ? cause[3].getClassName() : "none";
      String callingParent = cause.length > 3 ? cause[4].getClassName() : "none";
      // FML is allowed to call system exit and the Minecraft applet (from the quit button), and the
      // dedicated server (from itself)
      if (!(callingClass.startsWith("cpw.mods.fml.")
          || ("net.minecraft.client.Minecraft".equals(callingClass)
              && "net.minecraft.client.Minecraft".equals(callingParent))
          || ("net.minecraft.server.dedicated.DedicatedServer".equals(callingClass)
              && "net.minecraft.server.MinecraftServer".equals(callingParent)))) {
        throw new ExitTrappedException();
      }
    }