Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#242 Interfaces need not have java.lang.Object as superclass

open
nobody
None
5
2005-08-25
2005-08-25
Nigel
No

> cat t96.java
interface A {
void a();

void b();
}
interface B extends A {

void c();
}
class MyClass implements B {

public void a() {
System.out.println("Nigel is best");
}

public void b() {
System.out.println("Nigel is really best");
}

public void c() {
System.out.println("Nigel is totally best");
}
}

class t96 {

public static void main(String[] arg) {
MyClass o = new MyClass();

o.a();
o.b();
o.c();
}
}

Process cat exited with code 0

using java:

> javac t96.java
Process javac exited with code 0
> java t96
Nigel is best
Nigel is really best
Nigel is totally best
Process java exited with code 0

but using BeanShell:

> java -classpath /opt/bsh-2.0b5.jar:. bsh.Interpreter
t96.java
Exception in thread "main" java.lang.ClassFormatError:
Interfaces must have java.lang.Object as superclass in
class file B
at java.lang.ClassLoader.defineClass1(Native
Method)
at java.lang.ClassLoader.defineClass
(ClassLoader.java:620)
at java.lang.ClassLoader.defineClass
(ClassLoader.java:465)
at
bsh.classpath.DiscreteFilesClassLoader.findClass
(DiscreteFilesClassLoader.java:84)
at bsh.classpath.BshClassLoader.loadClass
(BshClassLoader.java:111)
at java.lang.ClassLoader.loadClass
(ClassLoader.java:251)
at
bsh.classpath.ClassManagerImpl.classForName
(ClassManagerImpl.java:171)
at
bsh.classpath.ClassManagerImpl.defineClass
(ClassManagerImpl.java:536)
at
bsh.ClassGeneratorImpl.generateClassImpl
(ClassGeneratorImpl.java:123)
at bsh.ClassGeneratorImpl.generateClass
(ClassGeneratorImpl.java:25)
at bsh.BSHClassDeclaration.eval
(BSHClassDeclaration.java:92)
at bsh.Interpreter.eval(Interpreter.java:645)
at bsh.Interpreter.source(Interpreter.java:571)
at bsh.Interpreter.main(Interpreter.java:360)
Process java exited with code 1

Discussion