samples/insertsuperclass/src-impl/org/apidesign/insertsuperclass/test/Main.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Thu, 30 Oct 2014 20:46:27 +0100
changeset 408 9a439a79c6d0
parent 277 34370a93db6b
permissions -rw-r--r--
Use scala 2.10.4 to compile on JDK8
jtulach@12
     1
jtulach@278
     2
package org.apidesign.insertsuperclass.test;
jtulach@12
     3
jtulach@278
     4
import org.apidesign.insertsuperclass.api.HelloClass;
jtulach@278
     5
import org.apidesign.insertsuperclass.api.HelloFieldClass;
jtulach@278
     6
import org.apidesign.insertsuperclass.api.HelloInterface;
jtulach@12
     7
jtulach@12
     8
/**
jtulach@12
     9
 *
jtulach@12
    10
 * @author Jaroslav Tulach <jtulach@netbeans.org>
jtulach@12
    11
 */
jtulach@12
    12
public class Main {
jtulach@12
    13
    public static void main(String[] args) throws Exception {
jtulach@277
    14
        boolean assertionsOn = false;
jtulach@277
    15
        assert assertionsOn = true;
jtulach@277
    16
        if (!assertionsOn) {
jtulach@277
    17
            throw new IllegalStateException("Enable assertions!");
jtulach@277
    18
        }
jtulach@277
    19
        
jtulach@12
    20
        HelloClass clazz = new ImplClass();
jtulach@12
    21
        assert "Hello Unknown!".equals(clazz.sayHello());
jtulach@12
    22
        assert "Hello Jaroslav!".equals(clazz.sayHelloTo("Jaroslav"));
jtulach@277
    23
        System.err.println("Who defines sayHello(): " + clazz.getClass().getSuperclass().getMethod("sayHello"));
jtulach@12
    24
jtulach@12
    25
        HelloInterface iface = new ImplInterface();
jtulach@12
    26
        assert "Hello Unknown!".equals(iface.sayHello());
jtulach@12
    27
        assert "Hello Jaroslav!".equals(iface.sayHelloTo("Jaroslav"));
jtulach@277
    28
        System.err.println("Who defines sayHello(): " + iface.getClass().getInterfaces()[0].getMethod("sayHello"));
jtulach@12
    29
        
jtulach@277
    30
        HelloFieldClass fieldClass = new HelloFieldClass();
jtulach@277
    31
        assert "Hello".equals(fieldClass.field);
jtulach@277
    32
        System.err.println("Who defines field: " + fieldClass.getClass().getField("field"));
jtulach@12
    33
    }
jtulach@12
    34
}