public Class instanceClass () throws java.io.IOException, ClassNotFoundException { return instanceClass(null); }
public boolean instanceOf (Class type) { try { return type.isAssignableFrom (instanceClass ()); } catch (IOException ex) { return false; } catch (ClassNotFoundException ex) { return false; } }
/** Is this an interface? * @return <code>true</code> if the class is an interface * @deprecated This method probably should not be used, as it catches a variety of potentially * serious exceptions and errors, and swallows them so as to produce a simple boolean * result. (Notifying them all would be inappropriate as they typically come from user * code.) Better to directly parse the bytecode, using e.g. the classfile module, * which is immune to this class of errors. */ public boolean isInterface () { try { return instanceClass ().isInterface (); } catch (IOException ex) { return false; } catch (ClassNotFoundException cnfe) { return false; } }
/** Is this a standalone executable? * @return <code>true</code> if this class has main method * (e.g., <code>public static void main (String[] arguments)</code>). * @deprecated This method probably should not be used, as it catches a variety of potentially * serious exceptions and errors, and swallows them so as to produce a simple boolean * result. (Notifying them all would be inappropriate as they typically come from user * code.) Better to directly parse the bytecode, using e.g. the classfile module, * which is immune to this class of errors. */ public boolean isExecutable () { try { Method main = instanceClass ().getDeclaredMethod ("main", new Class[] { // NOI18N String[].class }); int m = main.getModifiers (); return Modifier.isPublic (m) && Modifier.isStatic (m) && Void.TYPE.equals ( main.getReturnType () ); } catch (Exception ex) { return false; } catch (LinkageError re) { // false when other errors occur (NoClassDefFoundError etc...) return false; } }
Class clazz = instanceClass(); int modif = clazz.getModifiers (); if (!Modifier.isPublic (modif) || Modifier.isAbstract (modif)) {
/** Uses cache to remember list of classes to them this object is * assignable. */ public Class instanceClass() throws IOException, ClassNotFoundException { Class type = super.instanceClass (customClassLoader); updateListOfClasses (type, entry ().getFile ()); return type; }
return o; } else { Class c = instanceClass (); if (SharedClassObject.class.isAssignableFrom (c)) {