Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

a ClassLoader question

1 view
Skip to first unread message

udoline

unread,
Mar 26, 2001, 10:56:03 AM3/26/01
to
motivation protected the CLAZZ BINARY CODE

Tester.class is with JCE (www.cryptix.org) encrypted.

the interface ITester and die superclass proto are known by the
SystemClassLoader
and it will be safe executed. =8-)

on Exception call the Parent of SystemClassLoader,
by casting the class Tester ( call the standard constructors ),
it does'nt know my ClassLoader (JarFileClassLoader)
and will be gived up by false binary class code format ( no 0xCAFE byte).
=9-(

how can substitute the SystemClassLoader (Parent) to my own
to handle correct the encrypted class Tester.class ?

my programmerlatein in this way, is on the ende.

ThanX for any hints !

--
udoline 96I

------------------<% CUT

extract of cmd-console.:
+ mv -vf proto.class testen/
proto.class -> testen/proto.class
+ java Crypt -e Tester.class udoline
+++-e+++Tester.class+++udoline
doing crypt
+ mv -vf Tester.class ITester.class testen/
Tester.class -> testen/Tester.class
ITester.class -> testen/ITester.class
+ mv -vf encoded testen/Tester.class
encoded -> testen/Tester.class
+ cd testen
+ jar -cvf test.jar Tester.class ITester.class proto.class
added manifest
adding: Tester.class(in = 633) (out= 638)(deflated 0%)
adding: ITester.class(in = 174) (out= 144)(deflated 17%)
adding: proto.class(in = 313) (out= 231)(deflated 26%)
+ rm -fv ITester.class Tester.class proto.class
ITester.class
Tester.class
proto.class
+ cd -
$ java LoadTester udoline
use password: udoline

prefix hack: java.lang.ClassFormatError: Tester (Bad magic number)
Created (default contructor)
my clazzname is: Tester
ITester: im Objekt!
proto(super): im Objekt!
Exception in thread "main" java.lang.ClassFormatError: Tester (Bad magic
number)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:477)
at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:109)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
at java.net.URLClassLoader.access$1(URLClassLoader.java:216)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:191)
at java.lang.ClassLoader.loadClass(ClassLoader.java, Compiled Code)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:285)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:314)
at LoadTester.main(LoadTester.java)


%%%%%%%%%%%%%%%%%%%%%%%%%%%%
public class LoadTester
{

public static void main (String args[])
{
System.out.println("use password: "+args[0]+"\n");

JarFileClassLoader loader = null;
Class c = null ;

try {
loader = new JarFileClassLoader("testen/test.jar", args[0]);
// load from filesystem or jar file
c = loader.loadClass ("Tester");

int params = 0;

ITester itester = null;
proto tester = null;
Tester t = null;

Object o = c.newInstance();
System.out.println( "my clazzname is: " + c.getName() );

itester = (ITester) o;
System.out.println( "ITester: " + itester.message() );

tester = (proto) o;
System.out.println( "proto(super): " + tester.message() );

// FEHLER AB CAST
t = (Tester) o;
System.out.println( "Tester: " + t.message() );


}
catch( Exception e ){
System.err.println( "hier ging was schief ?\n");
e.printStackTrace();
}
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%
p
ublic class Tester extends proto implements ITester {

public static Tester t = null;

public Tester() {
t = this
System.out.println ("Created (default contructor)");
}

public String message(){

// String result = super.message() + ", " + new String("im Objekt!");
String result = new String("im Objek
t!");
return result;
}

}
%%%%%%%%%%%%%%%%%%%%%%%%%%%
public abstract class proto extends Object
{
public String message()
{
String result = new String("Abstract");
return result;
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%
public interface ITester {

public abstract int getInstance( Tester [] tester, int params );

public abstract String message();

}

%%%%%%%%%%%%%%%%%%%%%%%%%%%

0 new messages