@Override protected Class<?> loadClass(String className, boolean resolve) throws ClassNotFoundException { for (ClassLoader cl : uniqueCls) { final Class<?> res = cl.loadClass(className); if (res != null) { return res; } } throw new ClassNotFoundException("cannot find class: " + className); } };
@Override protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { for (String mask : masksClasses) { if(name.startsWith(mask)) throw new ClassNotFoundException(); } return super.loadClass(name, resolve); }
@Override protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { synchronized (this) { if (filteredClassNames.contains(name)) { throw new ClassNotFoundException(name); } else { return super.loadClass(name, resolve); } } } }
private void readObject(final ObjectInputStream in) throws ClassNotFoundException { throw new ClassNotFoundException(SerializationUtilsTest.CLASS_NOT_FOUND_MESSAGE); } }
Class getType(ClassLoader cl) throws ClassNotFoundException { if (type == null) throw new ClassNotFoundException("no array type specified"); Object a = Array.newInstance(type.getType(cl), 0); return a.getClass(); }
public <T extends RObject, K extends Codec> T createRObject(RedissonClient redisson, Class<T> expectedType, String name, K codec) throws Exception { List<Class<?>> interfaces = Arrays.asList(expectedType.getInterfaces()); for (Class<?> iType : interfaces) { if (references.containsKey(iType)) {// user cache to speed up things a little. Method builder = references.get(iType).get(codec != null); return (T) (codec != null ? builder.invoke(redisson, name) : builder.invoke(redisson, name, codec)); } } throw new ClassNotFoundException("No RObject is found to match class type of " + (expectedType != null ? expectedType.getName() : "null") + " with codec type of " + (codec != null ? codec.getClass().getName() : "null")); }
public <T extends RObject, K extends Codec> T createRObject(RedissonClient redisson, Class<T> expectedType, String name, K codec) throws Exception { List<Class<?>> interfaces = Arrays.asList(expectedType.getInterfaces()); for (Class<?> iType : interfaces) { if (references.containsKey(iType)) {// user cache to speed up things a little. Method builder = references.get(iType).get(codec != null); return (T) (codec != null ? builder.invoke(redisson, name) : builder.invoke(redisson, name, codec)); } } throw new ClassNotFoundException("No RObject is found to match class type of " + (expectedType != null ? expectedType.getName() : "null") + " with codec type of " + (codec != null ? codec.getClass().getName() : "null")); }
/** * @return the type * @throws java.lang.Exception - which could be: * LinkageError - if the linkage fails * ExceptionInInitializerError - if the initialization provoked by this method fails * ClassNotFoundException - if the class cannot be located */ public Class<?> getReactiveType() throws Exception { if (reactiveMap.containsValue(type)) { return Class.forName(reactiveMap.reverseGet(type));//live object is not supported in reactive client } throw new ClassNotFoundException("There is no Reactive compatible type for " + type); }
/** * @return the type * @throws java.lang.Exception - which could be: * LinkageError - if the linkage fails * ExceptionInInitializerError - if the initialization provoked by this method fails * ClassNotFoundException - if the class cannot be located */ public Class<?> getReactiveType() throws Exception { if (reactiveMap.containsValue(type)) { return Class.forName(reactiveMap.reverseGet(type));//live object is not supported in reactive client } throw new ClassNotFoundException("There is no Reactive compatible type for " + type); }
private Class<?> doLoadClass(String name) throws ClassNotFoundException { String internalName = StringUtils.replace(name, ".", "/") + ".class"; InputStream is = this.enclosingClassLoader.getResourceAsStream(internalName); if (is == null) { throw new ClassNotFoundException(name); } try { byte[] bytes = FileCopyUtils.copyToByteArray(is); bytes = applyTransformers(name, bytes); Class<?> cls = defineClass(name, bytes, 0, bytes.length); // Additional check for defining the package, if not defined yet. if (cls.getPackage() == null) { int packageSeparator = name.lastIndexOf('.'); if (packageSeparator != -1) { String packageName = name.substring(0, packageSeparator); definePackage(packageName, null, null, null, null, null, null, null); } } this.classCache.put(name, cls); return cls; } catch (IOException ex) { throw new ClassNotFoundException("Cannot load resource for class [" + name + "]", ex); } }
@Override protected Class<?> findClass(String name) throws ClassNotFoundException { byte[] bytecode = getClassBytes(name); if (bytecode == null) { throw new ClassNotFoundException(name); } return defineClass(name, bytecode, 0, bytecode.length); }
Class getType(ClassLoader cl) throws ClassNotFoundException { if (value == null) throw new ClassNotFoundException("no type specified"); else return loadClass(cl, value.getTypeName()); }
@Override protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { if (cnfThrowingClassnames.contains(name)) { throw new ClassNotFoundException(); } else { return super.loadClass(name, resolve); } } }
@Override public JobManagerMessages.DisposeSavepointFailure process(JobManagerMessages.DisposeSavepoint message) { return new JobManagerMessages.DisposeSavepointFailure(new ClassNotFoundException("Test Exception")); } }
/** * @@org.springframework.jmx.export.metadata.ManagedAttribute * (description="The Name Attribute", currencyTimeLimit=20, * defaultValue="bar", persistPolicy="OnUpdate") */ @Override public void setName(String name) throws Exception { if ("Juergen".equals(name)) { throw new IllegalArgumentException("Juergen"); } if ("Juergen Class".equals(name)) { throw new ClassNotFoundException("Juergen"); } if ("Juergen IO".equals(name)) { throw new IOException("Juergen"); } this.name = name; }
Object getValue(ClassLoader cl, ClassPool cp, Method m) throws ClassNotFoundException { try { return getType(cl).getField(getValue()).get(null); } catch (NoSuchFieldException e) { throw new ClassNotFoundException(getType() + "." + getValue()); } catch (IllegalAccessException e) { throw new ClassNotFoundException(getType() + "." + getValue()); } }
@Override public Class<?> loadClass(String name) throws ClassNotFoundException { if (blocklist.contains(name)) { throw new ClassNotFoundException("I'm sorry Dave, I'm afraid I can't do that."); } if (name.startsWith(concurrentPackage)) { Class<?> c = findLoadedClass(name); if (c == null) { return super.findClass(name); } return c; } return super.loadClass(name); } };
@Override public Class<?> loadClass(String name) throws ClassNotFoundException { if (disallowedClassNames.contains(name)) { throw new ClassNotFoundException("I'm sorry Dave, I'm afraid I can't do that."); } if (name.startsWith(concurrentPackage)) { Class<?> c = findLoadedClass(name); if (c == null) { return super.findClass(name); } return c; } return super.loadClass(name); } };
@Override public Verticle createVerticle(String verticleName, ClassLoader classLoader) throws Exception { if (failInCreate) { throw new ClassNotFoundException("whatever"); } this.identifier = verticleName; this.createContext = Vertx.currentContext(); this.createWorkerThread = Context.isOnWorkerThread(); return verticle; }
@Test public void unresolvableClass() throws Exception { attributes.put("unresolvableClass", new ClassNotFoundException("myclass")); exception.expect(IllegalArgumentException.class); exception.expectMessage(containsString("myclass")); attributes.getClass("unresolvableClass"); }