private Object decodeObject(String base64String) throws PersistentVarsException { Object object = null; try { byte[] bytes = Base64.getInstance().decode(base64String); InputStream inputStream = new ByteArrayInputStream(bytes); ObjectInputStream objectStream = new ObjectInputStream(inputStream); object = objectStream.readObject(); objectStream.close(); inputStream.close(); } catch (ClassNotFoundException classNotFoundException) { throw new PersistentVarsException(classNotFoundException.getMessage()); } catch (IOException ioException) { throw new PersistentVarsException(ioException.getMessage()); } return object; }
private BadClassFiles() throws ClassNotFoundException { classes = new Class<?>[] { loader.defineClass("EmptyName", EmptyName_bytes), loader.defineClass("BadModifiers", BadModifiers_bytes), loader.defineClass("BadNameIndex", BadNameIndex_bytes), loader.defineClass("NameIndexOutOfBounds", NameIndexOutOfBounds_bytes), loader.defineClass("ExtraParams", ExtraParams_bytes), // Name with . loader.defineClass("BadName1", BadName1_bytes), // Name with [ loader.defineClass("BadName2", BadName2_bytes), // Name with ; loader.defineClass("BadName3", BadName3_bytes), // Name with / loader.defineClass("BadName4", BadName4_bytes) }; }
private BadClassFiles() throws ClassNotFoundException { classes = new Class<?>[] { loader.defineClass("EmptyName", EmptyName_bytes), loader.defineClass("BadModifiers", BadModifiers_bytes), loader.defineClass("BadNameIndex", BadNameIndex_bytes), loader.defineClass("NameIndexOutOfBounds", NameIndexOutOfBounds_bytes), loader.defineClass("ExtraParams", ExtraParams_bytes), loader.defineClass("BadParams", BadParams_bytes), // Name with . loader.defineClass("BadName1", BadName1_bytes), // Name with [ loader.defineClass("BadName2", BadName2_bytes), // Name with ; loader.defineClass("BadName3", BadName3_bytes), // Name with / loader.defineClass("BadName4", BadName4_bytes) }; }
/** * RunList * suitesToRun: a Vector of suites from RunSuite * outDir: The output directory for the suite(s) * pwOut: The output for writing suite and test results * suiteProperties: From RunSuite for the top suite * (individual suites in the vector may have their own * properties which must also be located and applied) */ public RunList(Vector suitesToRun, File runDir, File outDir, PrintWriter pwOut, Properties suiteProperties, Properties specialProperties, String topParentSuite) throws ClassNotFoundException, IOException, Exception { this.runDir = runDir; this.outDir = outDir; this.pwOut = pwOut; this.suiteProperties = suiteProperties; // usual suite props this.specialProperties = specialProperties; // for special test Flags this.topSuiteName = suiteProperties.getProperty("suitename"); //System.out.println("----------------------------------------"); //System.out.println("RunList topSuiteName= " + topSuiteName); this.topParentSuite = topParentSuite; //System.out.println("topParentSuite= " + topParentSuite); // Run the suites runSuites(suitesToRun); }
static void verifyTestType() throws ClassNotFoundException, FileNotFoundException, IOException { //java requires '/' as separator to look into jar, irrespective of OS InputStream is = loadTestResource("harness/testtypes.properties"); Properties p = new Properties(); p.load(is); String testtypes = p.getProperty("testtypes"); StringTokenizer st = new StringTokenizer(testtypes,","); String ttype = ""; while (st.hasMoreTokens()) { ttype = st.nextToken(); if ( testType.equals(ttype) ) return; } // Not a known test type System.out.println("Unknown test type: " + testType); System.exit(1); }
public Learning() { jmhal = new JMegaHal(); // Reload brain from disk. try { FileInputStream fis = new FileInputStream(brainFile); ObjectInputStream ois = new ObjectInputStream(fis); Object object = ois.readObject(); if(object instanceof JMegaHal) jmhal = (JMegaHal)object; } catch(ClassNotFoundException cnfe) { System.out.println("> Warning: Class not found: " + cnfe.toString()); } catch(FileNotFoundException fnfe) { System.out.println("> Warning: Unable to open brain.dat: " + fnfe.toString()); } catch(IOException ioe) { System.out.println("> Warning: Unable to open brain.dat: " + ioe.toString()); } }
/** * Creates the node with the specified node id and fully qualified node type. * @param nodeID device ID * @param nodeType fully qualified node type (e.g. deviceType.softType) */ private AcceleratorNode createNode( final String nodeID, final String nodeType ) throws ClassNotFoundException { // Check if this node type is known; if not then substitute a generic node if ( !_constructors.containsKey( nodeType ) ) { final String message = "Unknown AcceleratorNode type : \"" + nodeType + "\" for ID: " + nodeID + ". Will substitute a GenericNode!"; System.err.println( message ); Logger.getLogger("global").log( Level.WARNING, message ); final AcceleratorNode node = new GenericNode( nodeType, nodeID, CHANNEL_FACTORY ); _classTable.put( nodeType, GenericNode.class ); return node; } final Constructor<?> constructor = _constructors.get( nodeType ); //TODO: need to account for custom channel factory final Object[] args = new Object[] { nodeID, CHANNEL_FACTORY }; try { return (AcceleratorNode)constructor.newInstance( args ); } catch (Throwable exception) { throw new ClassNotFoundException( "Unknown AcceleratorNode type : " + nodeType ); } }
@Test public void mixinCreateTest2( ) throws JsonProcessingException, ClassNotFoundException, IOException { Expression expression = new Expression( "contains", 0, 0 ) .addExpression( new Expression( "contains", 0, 0 ) .addTerm( "word", "aword0" ) .addTerm( "word", "aword1" ) ) .addTerm( "word", "aword2" ); ExpressionFeature f = new ExpressionFeature( "feat", expression, 1.0f ); StrusJsonObjectMapper mapperFactory = new StrusJsonObjectMapper( ); ObjectMapper mapper = mapperFactory.getObjectMapper( ); String s = mapper.writeValueAsString( f ); LOGGER.fine( s ); Object o = mapper.readValue( s, ExpressionFeature.class ); LOGGER.fine( o.toString( ) ); printNode( ((ExpressionFeature)o).expression, 1 ); }
private void initClassifier (PrintStream output) { try { classifier = CRFClassifier.getClassifier (serializedClassifier); } catch (ClassNotFoundException cnfe) { output.println ("Class not found exception initializing NER extractions."); output.println ("Exception: " + cnfe.toString ()); System.exit (1); } catch (IOException ioex) { output.println ("Exception in initClassifier"); output.println ("Exception: " + ioex.toString ()); System.exit (1); } }
public static String loadAuthenticationFilter() { // Check if custom AuthFilter is available String customAuthFilterClassName = JiveGlobals.getProperty(CUSTOM_AUTH_PROPERTY_NAME); String restAuthType = JiveGlobals.getProperty(REST_AUTH_TYPE); String pickedAuthFilter = AUTHFILTER; try { if(customAuthFilterClassName != null && "custom".equals(restAuthType)) { Class.forName(customAuthFilterClassName, false, JerseyWrapper.class.getClassLoader()); pickedAuthFilter = customAuthFilterClassName; loadingStatusMessage = null; } } catch (ClassNotFoundException e) { loadingStatusMessage = "No custom auth filter found for restAPI plugin! " + customAuthFilterClassName + " " + restAuthType; } prc.getProperties().put(CONTAINER_REQUEST_FILTERS, pickedAuthFilter); return loadingStatusMessage; }
private List<Class> getListTypes(Field fld) { List<Class> listVals = new ArrayList<Class>(); if (fld != null && (fld.getType() == List.class || fld.getType() == ArrayList.class)) { ParameterizedType pt = (ParameterizedType) fld.getGenericType(); for (Type type: pt.getActualTypeArguments()) { if (type instanceof Class) { // Single dimensional ListOf listVals.add((Class) type); } else { // Multidimensional ListOf //listVals.add((new ArrayList<Object>()).getClass()); for (String sub: type.toString().split("<")) if (sub.indexOf("List") > 5) listVals.add((new ArrayList<Object>()).getClass()); else try { String cn = sub.substring(0, sub.indexOf(">")); listVals.add(Class.forName(cn)); } catch (ClassNotFoundException cnf) { throw new Error ("Class not found: '"+sub+"'"); } } } } return listVals; }
/** * Display all the classes inheriting or implementing a given * interface in the currently loaded packages. * @param interfaceName the name of the interface to implement */ public static Set<String> implementations( String interfaceName ) { Set<String> list = new HashSet<String>(); try { Class toclass = Class.forName(interfaceName); //Package [] pcks = Package.getPackages(); //for (int i=0;i<pcks.length;i++) { //logger.trace(interfaceName+ ">> "+pcks[i].getName() ); //implementations( pcks[i].getName(), toclass, list ); //} implementations( toclass, list ); } catch (ClassNotFoundException ex) { logger.debug( "IGNORED Class {} not found!", interfaceName ); } return list; }
private static Class getPackageClass(String packageName) { Class packageClass; if(packageName == null || packageName.equals("base")) { packageClass = Base.class; } else if(packageName.equals("methods")) { packageClass = Methods.class; } else if(packageName.equals("grDevices")) { packageClass = Graphics.class; } else { String packageClassName = "org.renjin." + packageName + "." + packageName.substring(0, 1).toUpperCase() + packageName.substring(1); try { packageClass = Class.forName(packageClassName); } catch (ClassNotFoundException e) { throw new EvalException("Could not find class for 'native' methods for package '%s' (className='%s')", packageName, packageClassName); } } return packageClass; }
/** depth clone **/ public Object clone() { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(this); ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bis); return ois.readObject(); } catch (IOException | ClassNotFoundException e) { e.printStackTrace(); return null; } }
/** * Reads the contents of this message from the given input. */ public void fromData(DataInput in) throws IOException, ClassNotFoundException { this.regionPath = DataSerializer.readString(in); this.callbackArgument = DataSerializer.readObject(in); this.op = Operation.fromOrdinal(in.readByte()); this.originRemote = in.readBoolean(); this.distributedMember = DSFIDFactory.readInternalDistributedMember(in); }
/** * Create a new instance of a Checksum object. * @return The newly created Checksum object */ static public Checksum newInstance(String className) throws IOException { try { Class<?> clazz = getClassByName(className); return (Checksum)newInstance(clazz); } catch (ClassNotFoundException e) { throw new IOException(e); } }
static void BuildSuitesVector(String parent, String subsuites) throws ClassNotFoundException, IOException { Properties p; StringTokenizer st = new StringTokenizer(subsuites); String child = ""; while (st.hasMoreTokens()) { child = st.nextToken(); if (child.equals(parent)) { suitesToRun.addElement(parent+":"+child); //System.out.println("Add this: " + parent+":"+child); } else { p = getSuiteProperties(child, false); if ( p.getProperty("suites") == null ) { suitesToRun.addElement(parent+":"+child); //System.out.println("Add this: " + parent+":"+child); } else { String moresuites = p.getProperty("suites"); BuildSuitesVector(child, moresuites); } } } }
/** * Reads the contents of this message from the given input. */ public void fromData(DataInput in) throws IOException, ClassNotFoundException { this.regionPath = DataSerializer.readString(in); this.callbackArgument = DataSerializer.readObject(in); this.op = Operation.fromOrdinal(in.readByte()); this.originRemote = in.readBoolean(); this.distributedMember = DSFIDFactory.readInternalDistributedMember(in); this.diskException = DataSerializer.readObject(in); }
/** create an accelerator node based on a DataAdaptor */ public AcceleratorNode createNode( final DataAdaptor adaptor ) throws ClassNotFoundException { final String nodeID = adaptor.stringValue( "id" ); final String deviceType = adaptor.stringValue( "type" ); final String softType = adaptor.hasAttribute( "softType" ) ? adaptor.stringValue( "softType" ) : null; final String nodeType = softType != null ? deviceType + "." + softType : deviceType; return createNode( nodeID, nodeType ); }
@Test public void mixinCreateTest1( ) throws JsonProcessingException, ClassNotFoundException, IOException { TermFeature f = new TermFeature( "feat", 1.0f, "word", "aword0" ); StrusJsonObjectMapper mapperFactory = new StrusJsonObjectMapper( ); ObjectMapper mapper = mapperFactory.getObjectMapper( ); String s = mapper.writeValueAsString( f ); LOGGER.fine( s ); Object o = mapper.readValue( s, TermFeature.class ); LOGGER.fine( o.toString( ) ); LOGGER.fine( (((TermFeature)o).term).toString( ) ); printNode( ((TermFeature)o).term, 0 ); }
/** * Override readObject. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); // initialize our transient field digitList = new DigitList(); }
/** * Registers the events of the {@link ninja.amp.ampmenus.MenuListener} to a plugin. * * @param plugin The plugin used to register the events. */ public void register(JavaPlugin plugin) { if (!isRegistered(plugin)) { plugin.getServer().getPluginManager().registerEvents(INSTANCE, plugin); try { Class.forName("org.bukkit.event.inventory.InventoryDragEvent"); plugin.getServer().getPluginManager().registerEvents(new DragListener(), plugin); } catch (ClassNotFoundException e) { System.out.println("InventoryDragEvent not founded"); } this.plugin = plugin; } }
public static String tryLoadingAuthenticationFilter(String customAuthFilterClassName) { try { if(customAuthFilterClassName != null) { Class.forName(customAuthFilterClassName, false, JerseyWrapper.class.getClassLoader()); loadingStatusMessage = null; } } catch (ClassNotFoundException e) { loadingStatusMessage = "No custom auth filter found for restAPI plugin with name " + customAuthFilterClassName; } if(customAuthFilterClassName == null || customAuthFilterClassName.isEmpty()) loadingStatusMessage = "Classname field can't be empty!"; return loadingStatusMessage; }