# HG changeset patch # User Jaroslav Tulach # Date 1401280521 -7200 # Node ID d0df418a5993993ea68934593154ec01b2a3af24 # Parent a6f807104d8effc2061d3600aa5d01d5aed602c6 External classes are treated as exported. diff -r a6f807104d8e -r d0df418a5993 rt/vm/src/main/java/org/apidesign/vm4brwsr/VM.java --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/VM.java Wed May 28 13:38:29 2014 +0200 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/VM.java Wed May 28 14:35:21 2014 +0200 @@ -426,7 +426,7 @@ : object + "['" + mangledName + "']"; } - private static final class ExportedMethodFinder + private final class ExportedMethodFinder implements ClassDataCache.TraversalCallback { private final ExportedSymbols exportedSymbols; private MethodData found; @@ -438,7 +438,10 @@ @Override public boolean traverse(final MethodData methodData) { try { - if (exportedSymbols.isExported(methodData)) { + if ( + exportedSymbols.isExported(methodData) || + isExternalClass(methodData.cls.getClassName()) + ) { found = methodData; return false; } diff -r a6f807104d8e -r d0df418a5993 rt/vm/src/test/java/org/apidesign/vm4brwsr/ImplementExternalInterfaceTest.java --- a/rt/vm/src/test/java/org/apidesign/vm4brwsr/ImplementExternalInterfaceTest.java Wed May 28 13:38:29 2014 +0200 +++ b/rt/vm/src/test/java/org/apidesign/vm4brwsr/ImplementExternalInterfaceTest.java Wed May 28 14:35:21 2014 +0200 @@ -44,7 +44,7 @@ StringBuilder sb = new StringBuilder(); ScriptEngine[] eng = { null }; code = TestVM.compileClassAsExtension(sb, eng, - "org/apidesign/vm4brwsr/ImplementInterface", null, null + "org/apidesign/vm4brwsr/extrnl/ImplementInterface", null, null ); code = TestVM.compileClassesAsExtension(sb, eng, null, null, "org/apidesign/vm4brwsr/ImplementFactory", diff -r a6f807104d8e -r d0df418a5993 rt/vm/src/test/java/org/apidesign/vm4brwsr/ImplementFactory.java --- a/rt/vm/src/test/java/org/apidesign/vm4brwsr/ImplementFactory.java Wed May 28 13:38:29 2014 +0200 +++ b/rt/vm/src/test/java/org/apidesign/vm4brwsr/ImplementFactory.java Wed May 28 14:35:21 2014 +0200 @@ -17,6 +17,8 @@ */ package org.apidesign.vm4brwsr; +import org.apidesign.vm4brwsr.extrnl.ImplementInterface; + /** * * @author Jaroslav Tulach diff -r a6f807104d8e -r d0df418a5993 rt/vm/src/test/java/org/apidesign/vm4brwsr/ImplementInterface.java --- a/rt/vm/src/test/java/org/apidesign/vm4brwsr/ImplementInterface.java Wed May 28 13:38:29 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -/** - * Back 2 Browser Bytecode Translator - * Copyright (C) 2012 Jaroslav Tulach - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. Look for COPYING file in the top folder. - * If not, see http://opensource.org/licenses/GPL-2.0. - */ -package org.apidesign.vm4brwsr; - -/** - * - * @author Jaroslav Tulach - */ -public interface ImplementInterface { - public String sayHello(); -} diff -r a6f807104d8e -r d0df418a5993 rt/vm/src/test/java/org/apidesign/vm4brwsr/TestVM.java --- a/rt/vm/src/test/java/org/apidesign/vm4brwsr/TestVM.java Wed May 28 13:38:29 2014 +0200 +++ b/rt/vm/src/test/java/org/apidesign/vm4brwsr/TestVM.java Wed May 28 14:35:21 2014 +0200 @@ -26,7 +26,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Enumeration; +import java.util.HashSet; import java.util.List; +import java.util.Set; import javax.script.Invocable; import javax.script.ScriptContext; import javax.script.ScriptEngine; @@ -162,6 +164,11 @@ eng[0] = js; Bck2Brwsr.generate(sb, new EmulationResources()); } + Set exp = new HashSet(); + for (String n : names) { + int last = n.lastIndexOf('/'); + exp.add(n.substring(0, last + 1)); + } Bck2Brwsr b2b = Bck2Brwsr.newCompiler(). resources(new EmulationResources() { @Override @@ -174,7 +181,7 @@ }). addClasses(names). addResources("org/apidesign/vm4brwsr/obj.js"). - addExported("org/apidesign/vm4brwsr/"). + addExported(exp.toArray(new String[0])). obfuscation(ObfuscationLevel.FULL). library(); if (resourceName != null) { diff -r a6f807104d8e -r d0df418a5993 rt/vm/src/test/java/org/apidesign/vm4brwsr/extrnl/ImplementInterface.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rt/vm/src/test/java/org/apidesign/vm4brwsr/extrnl/ImplementInterface.java Wed May 28 14:35:21 2014 +0200 @@ -0,0 +1,26 @@ +/** + * Back 2 Browser Bytecode Translator + * Copyright (C) 2012 Jaroslav Tulach + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. Look for COPYING file in the top folder. + * If not, see http://opensource.org/licenses/GPL-2.0. + */ +package org.apidesign.vm4brwsr.extrnl; + +/** + * + * @author Jaroslav Tulach + */ +public interface ImplementInterface { + public String sayHello(); +}