mbeanServer.setAttribute(namingServiceObjectName, attr); } catch(ClassNotFoundException e) { LOG.debug("Probably not using JRE 1.4: {}", e.getLocalizedMessage()); } catch (Throwable e) { LOG.debug("Failed to create local registry. This exception will be ignored.", e);
@SuppressWarnings("rawtypes") private Class loadClass(AuthorizationPluginClassLoader loader, String name, boolean shouldFail) { Class clazz = null; try { clazz = loader.loadClass(name); if (shouldFail) { Assert.fail("Should produce some exception"); } } catch (ClassNotFoundException ex) { if (!shouldFail) { Assert.fail(String.format("Should not produce ClassNotFoundException: %s", ex.getLocalizedMessage())); } } catch (SecurityException ex) { if (!shouldFail) { Assert.fail(String.format("Should not produce SecurityException: %s", ex.getLocalizedMessage())); } } catch (Exception ex) { if (!shouldFail) { Assert.fail(String.format("Should not produce any exception: %s", ex.getLocalizedMessage())); } } return clazz; }
/** * Checks for the JAI library which is needed by the GrassCoverage datasource * * @return true if all libraries are available */ public boolean isAvailable() { boolean available = true; // if these classes are here, then the runtine environment has // access to JAI and the JAI ImageI/O toolbox. try { Class.forName("javax.media.jai.JAI"); Class.forName("com.sun.media.jai.operator.ImageReadDescriptor"); } catch (ClassNotFoundException e) { if (LOGGER.isLoggable(Level.FINE)) LOGGER.log(Level.FINE, e.getLocalizedMessage(), e); available = false; } return available; }
@SuppressWarnings("unchecked") protected final Object readResolve() throws ObjectStreamException { /* Second run */ if (this.userBean != null && this.userBeanBytes.length == 0) { return this.userBean; } /* First run */ try { final ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(this.userBeanBytes)); this.userBean = in.readObject(); this.unloadedProperties = (Map<String, ResultLoaderMap.LoadPair>) in.readObject(); this.objectFactory = (ObjectFactory) in.readObject(); this.constructorArgTypes = (Class<?>[]) in.readObject(); this.constructorArgs = (Object[]) in.readObject(); } catch (final IOException ex) { throw (ObjectStreamException) new StreamCorruptedException().initCause(ex); } catch (final ClassNotFoundException ex) { throw (ObjectStreamException) new InvalidClassException(ex.getLocalizedMessage()).initCause(ex); } final Map<String, ResultLoaderMap.LoadPair> arrayProps = new HashMap<String, ResultLoaderMap.LoadPair>(this.unloadedProperties); final List<Class<?>> arrayTypes = Arrays.asList(this.constructorArgTypes); final List<Object> arrayValues = Arrays.asList(this.constructorArgs); return this.createDeserializationProxy(userBean, arrayProps, objectFactory, arrayTypes, arrayValues); }
@SuppressWarnings("unchecked") protected final Object readResolve() throws ObjectStreamException { /* Second run */ if (this.userBean != null && this.userBeanBytes.length == 0) { return this.userBean; } /* First run */ try (ObjectInputStream in = new LookAheadObjectInputStream(new ByteArrayInputStream(this.userBeanBytes))) { this.userBean = in.readObject(); this.unloadedProperties = (Map<String, ResultLoaderMap.LoadPair>) in.readObject(); this.objectFactory = (ObjectFactory) in.readObject(); this.constructorArgTypes = (Class<?>[]) in.readObject(); this.constructorArgs = (Object[]) in.readObject(); } catch (final IOException ex) { throw (ObjectStreamException) new StreamCorruptedException().initCause(ex); } catch (final ClassNotFoundException ex) { throw (ObjectStreamException) new InvalidClassException(ex.getLocalizedMessage()).initCause(ex); } final Map<String, ResultLoaderMap.LoadPair> arrayProps = new HashMap<>(this.unloadedProperties); final List<Class<?>> arrayTypes = Arrays.asList(this.constructorArgTypes); final List<Object> arrayValues = Arrays.asList(this.constructorArgs); return this.createDeserializationProxy(userBean, arrayProps, objectFactory, arrayTypes, arrayValues); }
LOGGER.fine("Unable to parse Histogram:" + e.getLocalizedMessage());
} catch (ClassNotFoundException e) { if (LOGGER.isLoggable(Level.WARNING)) LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e); return null; } finally {
private Class doConvertToClass(Object value) { Class clazz = null; if (value != null && value instanceof String && ((String) value).length() > 0) { try { clazz = Class.forName((String) value); } catch (ClassNotFoundException e) { throw new XWorkException(e.getLocalizedMessage(), e); } } return clazz; }
/** * @see patterntesting.runtime.monitor.ClasspathMonitorMBean#getSerialVersionUID(java.lang.String) */ public Long getSerialVersionUID(final String classname) throws IllegalAccessException { try { Class<?> clazz = Class.forName(classname); return getSerialVersionUID(clazz); } catch (ClassNotFoundException e) { log.info(classname + " not found (" + e.getLocalizedMessage() + ")"); return null; } }
public Method getUnfilteredMethod() { try { Class callingClass = Class.forName(stackTraceElement.getClassName()); Method matchingMethod = extractMethod(stackTraceElement, callingClass); if (matchingMethod != null) { return matchingMethod; } } catch (ClassNotFoundException classNotFoundIgnored) { logger.debug("Couldn't find class during Stack analysis: " + classNotFoundIgnored.getLocalizedMessage()); } catch (NoClassDefFoundError noClassDefFoundErrorIgnored) { logger.debug("Couldn't find class definition during Stack analysis: " + noClassDefFoundErrorIgnored.getLocalizedMessage()); } return null; }
public Method getMethod() { try { if (allowedClassName(stackTraceElement.getClassName()) && !lambda(stackTraceElement.getClassName())) { Class callingClass = Class.forName(stackTraceElement.getClassName()); return extractMethod(stackTraceElement, callingClass); } } catch (ClassNotFoundException classNotFoundIgnored) { logger.debug("Couldn't find class during Stack analysis: " + classNotFoundIgnored.getLocalizedMessage()); } catch (NoClassDefFoundError noClassDefFoundErrorIgnored) { logger.debug("Couldn't find class definition during Stack analysis: " + noClassDefFoundErrorIgnored.getLocalizedMessage()); } return null; }
@JRubyMethod public IRubyObject marshal_load(ThreadContext context, IRubyObject str) { try { ByteList byteList = str.convertToString().getByteList(); ByteArrayInputStream bais = new ByteArrayInputStream(byteList.getUnsafeBytes(), byteList.getBegin(), byteList.getRealSize()); ObjectInputStream ois = new JRubyObjectInputStream(context.runtime, bais); object = ois.readObject(); return this; } catch (IOException ioe) { throw context.runtime.newIOErrorFromException(ioe); } catch (ClassNotFoundException cnfe) { throw context.runtime.newTypeError("Class not found unmarshaling Java type: " + cnfe.getLocalizedMessage()); } }
@JRubyMethod public IRubyObject marshal_load(ThreadContext context, IRubyObject str) { try { ByteList byteList = str.convertToString().getByteList(); ByteArrayInputStream bais = new ByteArrayInputStream(byteList.getUnsafeBytes(), byteList.getBegin(), byteList.getRealSize()); ObjectInputStream ois = new JRubyObjectInputStream(context.runtime, bais); object = ois.readObject(); return this; } catch (IOException ioe) { throw context.runtime.newIOErrorFromException(ioe); } catch (ClassNotFoundException cnfe) { throw context.runtime.newTypeError("Class not found unmarshaling Java type: " + cnfe.getLocalizedMessage()); } }
@JRubyMethod(name="read_object", alias="readObject") public IRubyObject readObject() { try { return Java.getInstance(getRuntime(), impl.readObject()); } catch (IOException ioe) { throw getRuntime().newIOErrorFromException(ioe); } catch (ClassNotFoundException cnfe) { throw getRuntime().newNameError(cnfe.getLocalizedMessage(), cnfe.getMessage(), cnfe); } }
@JRubyMethod(name="read_object", alias="readObject") public IRubyObject readObject() { try { return Java.getInstance(getRuntime(), impl.readObject()); } catch (IOException ioe) { throw getRuntime().newIOErrorFromException(ioe); } catch (ClassNotFoundException cnfe) { throw getRuntime().newNameError(cnfe.getLocalizedMessage(), cnfe.getMessage(), cnfe); } }
@JRubyMethod(name="read_object", alias="readObject") public IRubyObject readObject() { try { return Java.getInstance(getRuntime(),impl.readObject()); } catch (IOException ioe) { throw getRuntime().newIOErrorFromException(ioe); } catch (ClassNotFoundException cnfe) { throw getRuntime().newNameError(cnfe.getLocalizedMessage(), cnfe.getMessage(), cnfe); } }
@JRubyMethod(name="read_object", alias="readObject") public IRubyObject readObject() { try { return Java.getInstance(getRuntime(),impl.readObject()); } catch (IOException ioe) { throw getRuntime().newIOErrorFromException(ioe); } catch (ClassNotFoundException cnfe) { throw getRuntime().newNameError(cnfe.getLocalizedMessage(), cnfe.getMessage(), cnfe); } }
@JRubyMethod public IRubyObject marshal_load(ThreadContext context, IRubyObject str) { try { ByteList byteList = str.convertToString().getByteList(); ByteArrayInputStream bais = new ByteArrayInputStream(byteList.getUnsafeBytes(), byteList.getBegin(), byteList.getRealSize()); ObjectInputStream ois = new JRubyObjectInputStream(context.runtime, bais); dataWrapStruct(ois.readObject()); return this; } catch (IOException ioe) { throw context.runtime.newIOErrorFromException(ioe); } catch (ClassNotFoundException cnfe) { throw context.runtime.newTypeError("Class not found unmarshaling Java type: " + cnfe.getLocalizedMessage()); } }
@JRubyMethod public IRubyObject marshal_load(ThreadContext context, IRubyObject str) { try { ByteList byteList = str.convertToString().getByteList(); ByteArrayInputStream bais = new ByteArrayInputStream(byteList.getUnsafeBytes(), byteList.getBegin(), byteList.getRealSize()); ObjectInputStream ois = new JRubyObjectInputStream(context.runtime, bais); dataWrapStruct(ois.readObject()); return this; } catch (IOException ioe) { throw context.runtime.newIOErrorFromException(ioe); } catch (ClassNotFoundException cnfe) { throw context.runtime.newTypeError("Class not found unmarshaling Java type: " + cnfe.getLocalizedMessage()); } }
@JRubyMethod public IRubyObject marshal_load(ThreadContext context, IRubyObject str) { try { ByteList byteList = str.convertToString().getByteList(); ByteArrayInputStream bais = new ByteArrayInputStream(byteList.getUnsafeBytes(), byteList.getBegin(), byteList.getRealSize()); dataWrapStruct(new JRubyObjectInputStream(context.runtime, bais).readObject()); return this; } catch (IOException ex) { throw context.runtime.newIOErrorFromException(ex); } catch (ClassNotFoundException ex) { throw context.runtime.newTypeError("Class not found unmarshaling Java type: " + ex.getLocalizedMessage()); } }