Skip to content
Permalink
Browse files
Introducing OldStackMapper for pre-JDK1.6 class files
  • Loading branch information
Jaroslav Tulach committed Sep 9, 2021
1 parent 017465e commit d2100cf0278d989ab483516457c95212bb016486
Showing 27 changed files with 1,909 additions and 578 deletions.

Large diffs are not rendered by default.

@@ -71,6 +71,18 @@
<artifactId>org-openide-util-lookup</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.5.6</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
@@ -100,7 +112,7 @@
</executions>
<configuration>
<systemProperties>
<vmtest.precompiled>.*</vmtest.precompiled>
<vmtest.precompiled>.*(emul|launch).*</vmtest.precompiled>
</systemProperties>
</configuration>
</plugin>
@@ -0,0 +1,55 @@
/**
* Back 2 Browser Bytecode Translator
* Copyright (C) 2012-2018 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
*
* 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.bck2brwsr.compact.tck;

import org.apidesign.bck2brwsr.vmtest.Compare;
import org.apidesign.bck2brwsr.vmtest.VMTest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.impl.StaticLoggerBinder;
import org.slf4j.spi.LoggerFactoryBinder;
import org.testng.annotations.Factory;

public class Target15Test {
@Compare
public String loadLoggerFactoryBinder() {
Class<LoggerFactoryBinder> c = LoggerFactoryBinder.class;
return c.getName();
}

@Compare
public String hasBinder() {
StaticLoggerBinder binder = StaticLoggerBinder.getSingleton();
if (binder == null) {
throw new IllegalStateException("No binder: " + binder);
}
return binder.getClass().getName();
}

@Compare
public String log() {
Logger log = LoggerFactory.getLogger(Target15Test.class);
log.trace("Hi there!");
return log.getName();
}

@Factory
public static Object[] create() {
return VMTest.create(Target15Test.class);
}
}
@@ -0,0 +1,53 @@
/**
* Back 2 Browser Bytecode Translator
* Copyright (C) 2012-2018 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
*
* 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.bck2brwsr.tck;

import org.apidesign.bck2brwsr.vmtest.Compare;
import org.apidesign.bck2brwsr.vmtest.VMTest;
import org.testng.annotations.Factory;

/**
*
* @author Jaroslav Tulach <jtulach@netbeans.org>
*/
public class PackagesTest {
class Inner {
}

@Compare
public String topMostPackage() {
return getClass().getPackage().getName();
}

@Compare
public String innerPackage() {
return new Inner().getClass().getPackage().getName();
}

@Compare
public boolean areTheSame() {
Package p1 = getClass().getPackage();
Package p2 = new Inner().getClass().getPackage();
return p1 == p2;
}

@Factory
public static Object[] create() {
return VMTest.create(PackagesTest.class);
}
}
@@ -55,7 +55,7 @@ public class ResourcesTest {
}
}
assert different : "Not all manifests should look like first one:\n" + first;
if (cnt > 40 && cnt < 50) {
if (cnt > 40 && cnt < 60) {
return "OK";
} else {
return "" + cnt;
@@ -0,0 +1,27 @@
/**
* Back 2 Browser Bytecode Translator
* Copyright (C) 2012-2018 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
*
* 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 java.lang;

public final class Package {
private Package() {
}

public static Package getPackage(String name) {
return null;
}
}
@@ -0,0 +1,27 @@
/**
* Back 2 Browser Bytecode Translator
* Copyright (C) 2012-2018 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
*
* 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.bck2brwsr.emul.fake;

import org.testng.annotations.Test;

public class JavaLangTest {
@Test
public void checkPackage() throws Exception {
JavaUtilTest.assertSignatures(Package.class);
}
}
@@ -36,6 +36,7 @@
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.net.URL;
import java.util.Objects;
import org.apidesign.bck2brwsr.core.Exported;
import org.apidesign.bck2brwsr.core.JavaScriptBody;
import org.apidesign.bck2brwsr.core.JavaScriptOnly;
@@ -1955,5 +1956,18 @@ private static void bck2BrwsrCnvrtVM() {
)
private static void castEx() {
}


public Package getPackage() {
if (isPrimitive() || isArray()) {
return null;
}

String jvmName = jvmName();
int lastSlash = jvmName.lastIndexOf('/');
if (lastSlash == -1) {
return Package.getPackage("");
}
String name = jvmName.substring(0, lastSlash).replace('/', '.');
return Package.getPackage(name);
}
}

0 comments on commit d2100cf

Please sign in to comment.