Commit 50a7915e authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Merging LabComm2014 into master branch, LabComm2013 in now considered

obsolete.
parents 23d7bf99 af74718b
...@@ -6,9 +6,9 @@ lib/c/liblabcomm.so.1 ...@@ -6,9 +6,9 @@ lib/c/liblabcomm.so.1
lib/c/liblabcomm2006.so.1 lib/c/liblabcomm2006.so.1
lib/c/liblabcomm2006.so lib/c/liblabcomm2006.so
lib/c/liblabcomm2006.a lib/c/liblabcomm2006.a
lib/c/liblabcomm2013.so.1 lib/c/liblabcomm2014.so.1
lib/c/liblabcomm2013.so lib/c/liblabcomm2014.so
lib/c/liblabcomm2013.a lib/c/liblabcomm2014.a
lib/c/test/test_labcomm lib/c/test/test_labcomm
lib/c/test/test_labcomm_basic_type_encoding lib/c/test/test_labcomm_basic_type_encoding
lib/c/test/test_labcomm_copy lib/c/test/test_labcomm_copy
...@@ -26,3 +26,7 @@ examples/twoway/gen/ ...@@ -26,3 +26,7 @@ examples/twoway/gen/
lib/csharp/labcomm.dll lib/csharp/labcomm.dll
lib/java/gen/ lib/java/gen/
lib/java/labcomm*.jar lib/java/labcomm*.jar
examples/simple/example_decoder
examples/simple/example_decoder06
examples/simple/example_encoder
examples/simple/example_encoder06
...@@ -268,7 +268,7 @@ aspect CS_Class { ...@@ -268,7 +268,7 @@ aspect CS_Class {
pp(env.getPrintStream()); pp(env.getPrintStream());
env.println("*/"); env.println("*/");
env.println(); env.println();
env.println("public class " + getName() + " : LabCommType {"); env.println("public class " + getName() + " : SampleType {");
env.println(); env.println();
env.indent(); env.indent();
getType().CS_emitInstance(env); getType().CS_emitInstance(env);
...@@ -284,11 +284,11 @@ aspect CS_Class { ...@@ -284,11 +284,11 @@ aspect CS_Class {
pp(env.getPrintStream()); pp(env.getPrintStream());
env.println("*/"); env.println("*/");
env.println(); env.println();
env.println("public class " + getName() + " : LabCommSample {"); env.println("public class " + getName() + " : Sample {");
env.println(); env.println();
env.indent(); env.indent();
getType().CS_emitInstance(env); getType().CS_emitInstance(env);
env.println("public interface Handler : LabCommHandler {"); env.println("public interface Handler : SampleHandler {");
env.print(" void handle("); env.print(" void handle(");
if (!isVoid()) { if (!isVoid()) {
getType().CS_emitType(env); getType().CS_emitType(env);
...@@ -297,21 +297,21 @@ aspect CS_Class { ...@@ -297,21 +297,21 @@ aspect CS_Class {
env.println(");"); env.println(");");
env.println("}"); env.println("}");
env.println(); env.println();
env.println("public static void register(LabCommDecoder d, Handler h) {"); env.println("public static void register(Decoder d, Handler h) {");
env.indent(); env.indent();
env.println("d.register(new Dispatcher(), h);"); env.println("d.register(new Dispatcher(), h);");
env.unindent(); env.unindent();
env.println("}"); env.println("}");
env.println(); env.println();
env.println("public static void register(LabCommEncoder e) {"); env.println("public static void register(Encoder e) {");
env.indent(); env.indent();
env.println("e.register(new Dispatcher());"); env.println("e.register(new Dispatcher());");
env.unindent(); env.unindent();
env.println("}"); env.println("}");
env.println(); env.println();
env.println("private class Dispatcher : LabCommDispatcher {"); env.println("private class Dispatcher : SampleDispatcher {");
env.indent(); env.indent();
env.println(); env.println();
env.println("public Type getSampleClass() {"); env.println("public Type getSampleClass() {");
...@@ -332,7 +332,7 @@ aspect CS_Class { ...@@ -332,7 +332,7 @@ aspect CS_Class {
env.unindent(); env.unindent();
env.println("}"); env.println("}");
env.println(); env.println();
env.println("public void decodeAndHandle(LabCommDecoder d, LabCommHandler h) {"); env.println("public void decodeAndHandle(Decoder d, SampleHandler h) {");
env.indent(); env.indent();
if (isVoid()) { if (isVoid()) {
env.println(getName() + ".decode(d);"); env.println(getName() + ".decode(d);");
...@@ -374,7 +374,7 @@ aspect CS_Class { ...@@ -374,7 +374,7 @@ aspect CS_Class {
} }
public void TypeDecl.CS_emitEncoder(CS_env env) { public void TypeDecl.CS_emitEncoder(CS_env env) {
env.print("public static void encode(LabCommEncoder e"); env.print("public static void encode(Encoder e");
if (!isVoid()) { if (!isVoid()) {
env.print(", "); env.print(", ");
getType().CS_emitType(env); getType().CS_emitType(env);
...@@ -389,7 +389,7 @@ aspect CS_Class { ...@@ -389,7 +389,7 @@ aspect CS_Class {
} }
public void SampleDecl.CS_emitEncoder(CS_env env) { public void SampleDecl.CS_emitEncoder(CS_env env) {
env.print("public static void encode(LabCommEncoder e"); env.print("public static void encode(Encoder e");
if (!isVoid()) { if (!isVoid()) {
env.print(", "); env.print(", ");
getType().CS_emitType(env); getType().CS_emitType(env);
...@@ -485,7 +485,7 @@ aspect CS_Class { ...@@ -485,7 +485,7 @@ aspect CS_Class {
public void Decl.CS_emitDecoder(CS_env env) { public void Decl.CS_emitDecoder(CS_env env) {
env.print("public static "); env.print("public static ");
getType().CS_emitType(env); getType().CS_emitType(env);
env.println(" decode(LabCommDecoder d) {"); env.println(" decode(Decoder d) {");
env.indent(); env.indent();
if (!isVoid()) { if (!isVoid()) {
getType().CS_emitType(env); getType().CS_emitType(env);
......
...@@ -1188,12 +1188,12 @@ aspect C_Signature { ...@@ -1188,12 +1188,12 @@ aspect C_Signature {
} }
} }
env.println("};"); env.println("};");
C_emitSizeofValue(env);
env.println("struct labcomm"+env.verStr+"_signature labcomm"+env.verStr+"_signature_" + env.println("struct labcomm"+env.verStr+"_signature labcomm"+env.verStr+"_signature_" +
env.prefix + getName() + " = {"); env.prefix + getName() + " = {");
env.indent(); env.indent();
env.println("LABCOMM_SAMPLE, \"" + getName() + "\","); env.println("\"" + getName() + "\",");
env.println("(int (*)(struct labcomm"+env.verStr+"_signature *, void *))labcomm"+env.verStr+"_sizeof_" + env.println("sizeof_" + env.prefix + getName() + ",");
env.prefix + getName() + ",");
env.println("sizeof(signature_bytes_" + env.prefix + getName() + "),"); env.println("sizeof(signature_bytes_" + env.prefix + getName() + "),");
env.println("signature_bytes_" + env.prefix + getName() + ","); env.println("signature_bytes_" + env.prefix + getName() + ",");
env.println("0"); env.println("0");
...@@ -1260,6 +1260,22 @@ aspect C_Sizeof { ...@@ -1260,6 +1260,22 @@ aspect C_Sizeof {
return getType().C_fixedSizeof(); return getType().C_fixedSizeof();
} }
public void Decl.C_emitSizeof(C_env env) {
}
public void SampleDecl.C_emitSizeof(C_env env) {
env = env.nestStruct("(*v)");
env.println("int labcomm"+env.verStr+"_sizeof_" + env.prefix + getName() +
"(" + env.prefix + getName() + " *v)");
env.println("{");
env.indent();
env.println("return labcomm"+env.verStr+"_internal_sizeof(" +
"&labcomm" + env.verStr+"_signature_" + env.prefix + getName() +
", v);");
env.unindent();
env.println("}");
}
public int Type.C_fixedSizeof() { public int Type.C_fixedSizeof() {
throw new Error(this.getClass().getName() + throw new Error(this.getClass().getName() +
".C_fixedSizeof()" + ".C_fixedSizeof()" +
...@@ -1308,18 +1324,17 @@ aspect C_Sizeof { ...@@ -1308,18 +1324,17 @@ aspect C_Sizeof {
return getType().C_fixedSizeof() * elements; return getType().C_fixedSizeof() * elements;
} }
public void Decl.C_emitSizeof(C_env env) { public void Decl.C_emitSizeofValue(C_env env) {
} }
public void SampleDecl.C_emitSizeof(C_env env) { public void SampleDecl.C_emitSizeofValue(C_env env) {
env = env.nestStruct("(*v)"); env = env.nestStruct("(*v)");
env.println("int labcomm"+env.verStr+"_sizeof_" + env.prefix + getName() + env.println("static int sizeof_" + env.prefix + getName() + "(void *vv)");
"(" + env.prefix + getName() + " *v)");
env.println("{"); env.println("{");
env.indent(); env.indent();
env.println("int result = labcomm"+env.verStr+"_size_packed32(labcomm"+env.verStr+"_signature_" + env.println("int result = 0;");
env.prefix + getName() +".index);");
if (C_isDynamic()) { if (C_isDynamic()) {
env.println(env.prefix + getName() + " *v = vv;");
getType().C_emitSizeof(env); getType().C_emitSizeof(env);
} else { } else {
env.println("result += " + C_fixedSizeof() + ";"); env.println("result += " + C_fixedSizeof() + ";");
...@@ -1338,7 +1353,8 @@ aspect C_Sizeof { ...@@ -1338,7 +1353,8 @@ aspect C_Sizeof {
public void PrimType.C_emitSizeof(C_env env) { public void PrimType.C_emitSizeof(C_env env) {
switch (getToken()) { switch (getToken()) {
case LABCOMM_STRING: { case LABCOMM_STRING: {
env.println("result += 0 + strlen(" + env.qualid + ");"); env.print("{ int l = strlen(" + env.qualid + "); ");
env.println("result += labcomm"+env.verStr+"_size_packed32(l) + l; }");
} break; } break;
default: { default: {
throw new Error(this.getClass().getName() + throw new Error(this.getClass().getName() +
......
...@@ -206,21 +206,6 @@ aspect Java_CodeGen { ...@@ -206,21 +206,6 @@ aspect Java_CodeGen {
public void Program.J_gen(PrintStream ps, String pack, int version) throws IOException { public void Program.J_gen(PrintStream ps, String pack, int version) throws IOException {
Java_env env; Java_env env;
/*
// Registration class
env = new Java_env(version, ps);
if (pack != null && pack.length() > 0) {
env.println("package " + pack + ";");
}
env.println("public class LabCommRegister {");
env.println();
env.indent();
Java_emitTypeRegister(env);
env.unindent();
env.println();
env.println("}");
// env.close();
*/
env = new Java_env(version, ps); env = new Java_env(version, ps);
for (int i = 0; i < getNumDecl(); i++) { for (int i = 0; i < getNumDecl(); i++) {
Decl d = getDecl(i); Decl d = getDecl(i);
...@@ -236,21 +221,6 @@ aspect Java_CodeGen { ...@@ -236,21 +221,6 @@ aspect Java_CodeGen {
public void Program.J_gen(String dir, String pack, int version) throws IOException { public void Program.J_gen(String dir, String pack, int version) throws IOException {
Java_env env; Java_env env;
/*
// Registration class
env = new Java_env(version, new File(dir, "LabCommRegister.java"));
if (pack != null && pack.length() > 0) {
env.println("package " + pack + ";");
}
env.println("public class LabCommRegister {");
env.println();
env.indent();
Java_emitTypeRegister(env);
env.unindent();
env.println();
env.println("}");
env.close();
*/
for (int i = 0; i < getNumDecl(); i++) { for (int i = 0; i < getNumDecl(); i++) {
Decl d = getDecl(i); Decl d = getDecl(i);
try { try {
...@@ -286,38 +256,6 @@ aspect Java_CodeGen { ...@@ -286,38 +256,6 @@ aspect Java_CodeGen {
} }
} }
} }
}
aspect Java_Register {
public void Program.Java_emitTypeRegister(Java_env env) {
/*
env.println("static void register(LabCommChannel c) {");
env.indent();
for (int i = 0; i < getNumDecl(); i++) {
getDecl(i).Java_emitTypeRegister(env);
}
env.unindent();
env.println("}");
*/
}
public void Decl.Java_emitTypeRegister(Java_env env) {
throw new Error(this.getClass().getName() +
".Java_emitTypeRegister(Java_env env)" +
" not declared");
}
public void SampleDecl.Java_emitTypeRegister(Java_env env) {
env.println(getName() + ".register(c);");
}
public void TypeDecl.Java_emitTypeRegister(Java_env env) {
// TODO
}
} }
aspect Java_Class { aspect Java_Class {
...@@ -340,11 +278,11 @@ aspect Java_Class { ...@@ -340,11 +278,11 @@ aspect Java_Class {
} }
env.println("import java.io.IOException;"); env.println("import java.io.IOException;");
env.println("import se.lth.control.labcomm"+env.verStr+".LabCommType;"); env.println("import se.lth.control.labcomm"+env.verStr+".SampleType;");
env.println("import se.lth.control.labcomm"+env.verStr+".LabCommEncoder;"); env.println("import se.lth.control.labcomm"+env.verStr+".Encoder;");
env.println("import se.lth.control.labcomm"+env.verStr+".LabCommDecoder;"); env.println("import se.lth.control.labcomm"+env.verStr+".Decoder;");
env.println(); env.println();
env.println("public class " + getName() + " implements LabCommType {"); env.println("public class " + getName() + " implements SampleType {");
env.println(); env.println();
env.indent(); env.indent();
getType().Java_emitInstance(env); getType().Java_emitInstance(env);
...@@ -380,21 +318,21 @@ aspect Java_Class { ...@@ -380,21 +318,21 @@ aspect Java_Class {
} }
env.println("import java.io.IOException;"); env.println("import java.io.IOException;");
env.println("import se.lth.control.labcomm"+env.verStr+".LabCommDecoder;"); env.println("import se.lth.control.labcomm"+env.verStr+".Decoder;");
env.println("import se.lth.control.labcomm"+env.verStr+".LabCommDispatcher;"); env.println("import se.lth.control.labcomm"+env.verStr+".SampleDispatcher;");
env.println("import se.lth.control.labcomm"+env.verStr+".LabCommEncoder;"); env.println("import se.lth.control.labcomm"+env.verStr+".Encoder;");
env.println("import se.lth.control.labcomm"+env.verStr+".LabCommHandler;"); env.println("import se.lth.control.labcomm"+env.verStr+".SampleHandler;");
env.println("import se.lth.control.labcomm"+env.verStr+".LabCommSample;"); env.println("import se.lth.control.labcomm"+env.verStr+".Sample;");
env.println(); env.println();
env.print("public class " + getName()); env.print("public class " + getName());
// if(getType().isUserType()) { // if(getType().isUserType()) {
// env.print(" extends "+getType().getTypeName()); // env.print(" extends "+getType().getTypeName());
// } // }
env.println(" implements LabCommSample {"); env.println(" implements Sample {");
env.println(); env.println();
env.indent(); env.indent();
getType().Java_emitInstance(env); getType().Java_emitInstance(env);
env.println("public interface Handler extends LabCommHandler {"); env.println("public interface Handler extends SampleHandler {");
env.print(" public void handle_" + getName() + "("); env.print(" public void handle_" + getName() + "(");
if (!isVoid()) { if (!isVoid()) {
getType().Java_emitType(env); getType().Java_emitType(env);
...@@ -403,21 +341,21 @@ aspect Java_Class { ...@@ -403,21 +341,21 @@ aspect Java_Class {
env.println(") throws Exception;"); env.println(") throws Exception;");
env.println("}"); env.println("}");
env.println(); env.println();
env.println("public static void register(LabCommDecoder d, Handler h) throws IOException {"); env.println("public static void register(Decoder d, SampleHandler h) throws IOException {");
env.indent(); env.indent();
env.println("d.register(new Dispatcher(), h);"); env.println("d.register(new Dispatcher(), h);");
env.unindent(); env.unindent();
env.println("}"); env.println("}");
env.println(); env.println();
env.println("public static void register(LabCommEncoder e) throws IOException {"); env.println("public static void register(Encoder e) throws IOException {");
env.indent(); env.indent();
env.println("e.register(new Dispatcher());"); env.println("e.register(new Dispatcher());");
env.unindent(); env.unindent();
env.println("}"); env.println("}");
env.println(); env.println();
env.println("private static class Dispatcher implements LabCommDispatcher {"); env.println("private static class Dispatcher implements SampleDispatcher {");
env.indent(); env.indent();
env.println(); env.println();
env.println("public Class getSampleClass() {"); env.println("public Class getSampleClass() {");
...@@ -438,8 +376,8 @@ aspect Java_Class { ...@@ -438,8 +376,8 @@ aspect Java_Class {
env.unindent(); env.unindent();
env.println("}"); env.println("}");
env.println(); env.println();
env.println("public void decodeAndHandle(LabCommDecoder d,"); env.println("public void decodeAndHandle(Decoder d,");
env.println(" LabCommHandler h) throws Exception {"); env.println(" SampleHandler h) throws Exception {");
env.indent(); env.indent();
if (isVoid()) { if (isVoid()) {
env.println(getName() + ".decode(d);"); env.println(getName() + ".decode(d);");
...@@ -481,7 +419,7 @@ aspect Java_Class { ...@@ -481,7 +419,7 @@ aspect Java_Class {
} }
public void TypeDecl.Java_emitEncoder(Java_env env) { public void TypeDecl.Java_emitEncoder(Java_env env) {
env.print("public static void encode(LabCommEncoder e"); env.print("public static void encode(Encoder e");
if (!isVoid()) { if (!isVoid()) {
env.print(", "); env.print(", ");
getType().Java_emitType(env); getType().Java_emitType(env);
...@@ -496,7 +434,7 @@ aspect Java_Class { ...@@ -496,7 +434,7 @@ aspect Java_Class {
} }
public void SampleDecl.Java_emitEncoder(Java_env env) { public void SampleDecl.Java_emitEncoder(Java_env env) {
env.print("public static void encode(LabCommEncoder e"); env.print("public static void encode(Encoder e");
if (!isVoid()) { if (!isVoid()) {
env.print(", "); env.print(", ");
getType().Java_emitType(env); getType().Java_emitType(env);
...@@ -588,7 +526,7 @@ aspect Java_Class { ...@@ -588,7 +526,7 @@ aspect Java_Class {
public void Decl.Java_emitDecoder(Java_env env) { public void Decl.Java_emitDecoder(Java_env env) {
env.print("public static "); env.print("public static ");
getType().Java_emitType(env); getType().Java_emitType(env);
env.println(" decode(LabCommDecoder d) throws IOException {"); env.println(" decode(Decoder d) throws IOException {");
env.indent(); env.indent();
if (!isVoid()) { if (!isVoid()) {
getType().Java_emitType(env); getType().Java_emitType(env);
......
...@@ -83,6 +83,7 @@ aspect Python_CodeGen { ...@@ -83,6 +83,7 @@ aspect Python_CodeGen {
env.println("import labcomm"); env.println("import labcomm");
env.println(); env.println();
Python_genTypes(env); Python_genTypes(env);
/* Typedefs curenntly disabled
env.println("typedef = ["); env.println("typedef = [");
env.indent(); env.indent();
for (int i = 0 ; i < getNumDecl() ; i++) { for (int i = 0 ; i < getNumDecl() ; i++) {
...@@ -90,6 +91,7 @@ aspect Python_CodeGen { ...@@ -90,6 +91,7 @@ aspect Python_CodeGen {
} }
env.unindent(); env.unindent();
env.println("]"); env.println("]");
*/
env.println("sample = ["); env.println("sample = [");
env.indent(); env.indent();
for (int i = 0 ; i < getNumDecl() ; i++) { for (int i = 0 ; i < getNumDecl() ; i++) {
...@@ -105,11 +107,7 @@ aspect PythonTypes { ...@@ -105,11 +107,7 @@ aspect PythonTypes {
public void Program.Python_genTypes(Python_env env) { public void Program.Python_genTypes(Python_env env) {
for (int i = 0 ; i < getNumDecl() ; i++) { for (int i = 0 ; i < getNumDecl() ; i++) {
env.println("class " + getDecl(i).getName() + "(object):");
env.indent();
getDecl(i).Python_genSignature(env); getDecl(i).Python_genSignature(env);
env.unindent();
env.println();
} }
} }
...@@ -120,19 +118,29 @@ aspect PythonTypes { ...@@ -120,19 +118,29 @@ aspect PythonTypes {
} }
public void TypeDecl.Python_genSignature(Python_env env) { public void TypeDecl.Python_genSignature(Python_env env) {
/*
env.println("class " + getName() + "(object):");
env.indent();
env.println("signature = labcomm.typedef('" + getName() + "',"); env.println("signature = labcomm.typedef('" + getName() + "',");
env.indent(); env.indent();
getType().Python_genSignature(env); getType().Python_genSignature(env);
env.unindent(); env.unindent();
env.println(")"); env.println(")");
env.unindent();
env.println();
*/
} }
public void SampleDecl.Python_genSignature(Python_env env) { public void SampleDecl.Python_genSignature(Python_env env) {
env.println("class " + getName() + "(object):");
env.indent();
env.println("signature = labcomm.sample('" + getName() + "', "); env.println("signature = labcomm.sample('" + getName() + "', ");
env.indent(); env.indent();
getType().Python_genSignature(env); getType().Python_genSignature(env);
env.unindent(); env.unindent();
env.println(")"); env.println(")");
env.unindent();
env.println();
} }
public void UserType.Python_genSignature(Python_env env) { public void UserType.Python_genSignature(Python_env env) {
......
...@@ -18,12 +18,12 @@ import java.util.Iterator; ...@@ -18,12 +18,12 @@ import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Map; import java.util.Map;
import se.lth.control.labcomm.LabCommDecoder; import se.lth.control.labcomm.Decoder;
import se.lth.control.labcomm.LabCommDecoderChannel; import se.lth.control.labcomm.DecoderChannel;
import se.lth.control.labcomm.LabCommEncoder; import se.lth.control.labcomm.Encoder;
import se.lth.control.labcomm.LabCommEncoderChannel; import se.lth.control.labcomm.EncoderChannel;
import AST.LabCommParser; import AST.Parser;
import AST.LabCommScanner; import AST.Scanner;
import AST.Program; import AST.Program;
import beaver.Parser.Exception; import beaver.Parser.Exception;
...@@ -160,8 +160,8 @@ public class DynamicPart { ...@@ -160,8 +160,8 @@ public class DynamicPart {
public static InRAMCompiler generateCode(String lcDecl, HashMap<String, String> handlers) { public static InRAMCompiler generateCode(String lcDecl, HashMap<String, String> handlers) {
Program ast = null; Program ast = null;
InputStream in = new ByteArrayInputStream(lcDecl.getBytes()); InputStream in = new ByteArrayInputStream(lcDecl.getBytes());
LabCommScanner scanner = new LabCommScanner(in); Scanner scanner = new Scanner(in);
LabCommParser parser = new LabCommParser(); Parser parser = new Parser();
Collection errors = new LinkedList(); Collection errors = new LinkedList();
InRAMCompiler irc = null; InRAMCompiler irc = null;
...@@ -272,7 +272,7 @@ public class DynamicPart { ...@@ -272,7 +272,7 @@ public class DynamicPart {
private void decodeTest(InRAMCompiler irc, HandlerContext ctxt, String tmpFile, String... sampleNames) { private void decodeTest(InRAMCompiler irc, HandlerContext ctxt, String tmpFile, String... sampleNames) {
try { try {
FileInputStream in = new FileInputStream(tmpFile); FileInputStream in = new FileInputStream(tmpFile);
LabCommDecoderChannel dec = new LabCommDecoderChannel(in); DecoderChannel dec = new DecoderChannel(in);
Class handlerClass = irc.load(handlerClassName); Class handlerClass = irc.load(handlerClassName);
Constructor hcc = handlerClass.getDeclaredConstructor(Object.class); Constructor hcc = handlerClass.getDeclaredConstructor(Object.class);
Object handler = hcc.newInstance(ctxt); Object handler = hcc.newInstance(ctxt);
...@@ -282,7 +282,7 @@ public class DynamicPart { ...@@ -282,7 +282,7 @@ public class DynamicPart {
Class sampleClass = irc.load(sampleName); Class sampleClass = irc.load(sampleName);
Class handlerInterface = irc.load(sampleName+"$Handler"); Class handlerInterface = irc.load(sampleName+"$Handler");
Method reg = sampleClass.getDeclaredMethod("register", LabCommDecoder.class, handlerInterface); Method reg = sampleClass.getDeclaredMethod("register", Decoder.class, handlerInterface);
reg.invoke(sampleClass, dec, handler); reg.invoke(sampleClass, dec, handler);
} }