List of usage examples for java.lang Class getClassLoader
@CallerSensitive
@ForceInline
public ClassLoader getClassLoader()
From source file:Main.java
public static void main(String[] args) throws Exception { Class cls = Class.forName("Main"); ClassLoader cLoader = cls.getClassLoader(); Class cls2 = Class.forName("java.lang.Thread", true, cLoader); System.out.println("Class = " + cls.getName()); System.out.println("Class = " + cls2.getName()); }
From source file:Main.java
public static void main(String[] args) throws Exception { Class cls = Class.forName("java.lang.String"); // returns the ClassLoader object associated with this Class. ClassLoader cLoader = cls.getClassLoader(); if (cLoader == null) { System.out.println("The default system class was used."); } else {//from w w w .j a va 2 s . com // returns the class loader Class loaderClass = cLoader.getClass(); System.out.println(loaderClass.getName()); } }
From source file:org.brutusin.instrumentation.SimpleClass.java
public static void main(String[] args) throws Exception { Class clazz = SimpleClass.class; String className = clazz.getCanonicalName(); String resourceName = className.replace('.', '/') + ".class"; InputStream is = clazz.getClassLoader().getResourceAsStream(resourceName); byte[] bytes = IOUtils.toByteArray(is); Helper.viewByteCode(bytes);/*from ww w . j a v a 2 s.com*/ }
From source file:Main.java
public static <T> Map<String, T> fromBundle(Bundle input, Class<T> claz) { input.setClassLoader(claz.getClassLoader()); Map<String, T> output = new ArrayMap<String, T>(); for (String key : input.keySet()) { output.put(key, (T) input.get(key)); }// ww w .j av a 2 s . c o m return output; }
From source file:Main.java
public static String getAbsoluteClassPath(Class<?> clazz) { String classPath = clazz.getClassLoader().getResource("/").getPath(); // For Windows if ("\\".equals(File.separator)) { classPath = classPath.substring(1).replace("/", "\\"); }//from www . jav a 2s . c om // For Linux if ("/".equals(File.separator)) { classPath = classPath.replace("\\", "/"); } return classPath; }
From source file:Main.java
public static Drawable getDrawable(Class clazz, String path) { InputStream is = clazz.getClassLoader().getResourceAsStream(path); return Drawable.createFromStream(is, path); }
From source file:Main.java
public static Picture getPicture(final Class<? extends Object> clazz, String path) { InputStream is = clazz.getClassLoader().getResourceAsStream(path); return Picture.createFromStream(is); }
From source file:Main.java
public static BitmapDrawable getBitmapDrawable(final Class<? extends Object> clazz, String path) { InputStream is = clazz.getClassLoader().getResourceAsStream(path); return (BitmapDrawable) BitmapDrawable.createFromStream(is, path); }
From source file:Main.java
public static Drawable getDrawable(final Class<? extends Object> clazz, String path) { InputStream is = clazz.getClassLoader().getResourceAsStream(path); return Drawable.createFromStream(is, path); }
From source file:org.code_house.service.jolokia.Jolokia.java
public static <T> T newMBeanProxy(J4pClient connection, ObjectName objectName, Class<T> interfaceClass) { return (T) Proxy.newProxyInstance(interfaceClass.getClassLoader(), new Class[] { interfaceClass }, new Jolokia(connection, objectName)); }