public Class getNewClass ( ) throws IllegalStateException , ClassFormatError { if ( mClass != null ) { return mClass ; } ByteArrayOutputStream data = mData ; if ( data == null ) { throw new IllegalStateException ( "Class not defined yet" ) ; } byte [ ] bytes = data . toByteArray ( ) ; if ( DEBUG ) { File file = new File ( mName . replace ( ' ' , ' ' ) + ".class" ) ; try { File tempDir = new File ( System . getProperty ( "java.io.tmpdir" ) ) ; file = new File ( tempDir , file . getPath ( ) ) ; } catch ( SecurityException e ) { } try { file . getParentFile ( ) . mkdirs ( ) ; System . out . println ( "ClassInjector writing to " + file ) ; OutputStream out = new FileOutputStream ( file ) ; out . write ( bytes ) ; out . close ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } mClass = mLoader . define ( mName , bytes ) ; mData = null ; return mClass ; }
Returns the newly defined class .