Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
abd133a
Implements java.util.Logger (untested)
Oct 14, 2019
867eb43
makes AWT panel act like canvas, always painting its background without
Oct 14, 2019
fca41d7
Implements Java8 getBaseName()
Oct 14, 2019
8718d7f
adds java.util.logging package
Oct 14, 2019
8b8f0aa
fix for popup menu not updating if it is changed while already open
Oct 14, 2019
71b7839
just making constants list of all the .j2s directives
Oct 14, 2019
32c32ed
removing Logger calls in javax.xml
Oct 17, 2019
b5e4516
JAL-3261 broken reader - SwingJS issue
Oct 17, 2019
fbb6d63
// BH 2019.10.18 fix for "P$.licationShutdownHooks$1"
Oct 17, 2019
68a2dd3
Class.getFields() broken; not giving static fields
Oct 19, 2019
0437aca
XML classes using java.util.logging.Loggger
Oct 19, 2019
4752683
ObjectInputStream using unimplemented ReferenceQueue
Oct 19, 2019
2c09580
_ variable for catch switched to "e"
Oct 19, 2019
9f9f4a4
comment
Oct 19, 2019
0be32ff
proper System.exit(status)
Oct 19, 2019
0115290
java.logging.Logger support
Oct 19, 2019
a3a3866
Merge branch 'hanson1' of https://github.com/BobHanson/java2script.gi…
Oct 19, 2019
fb0d286
j2sheadless should fire System.exit(0) after running main.
Oct 19, 2019
15572f6
bug in code, not SwingJS
Oct 19, 2019
444fef8
new SwingJS-site.zip
Oct 19, 2019
644a8a9
removes testing message
Oct 20, 2019
d4dd845
updates System.exit(0) info
Oct 20, 2019
08e3ec1
A placeholder for window.SwingJS
Oct 20, 2019
ea79a2c
enables ThreadGroup
Oct 20, 2019
77eb9a1
build-site allows for missing directories
Oct 20, 2019
69e2a47
fixes for multiple applets and applications
Oct 20, 2019
14badb5
new SwingJS-site.zip
Oct 20, 2019
769c80a
Merge pull request #116 from BobHanson/hanson1
BobHanson Oct 21, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions sources/net.sf.j2s.core/dist/build-site.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

<for param="file.zip">
<path>
<fileset dir="${libjs.dir}" includes="*.zip"/>
<fileset dir="${libjs.dir}" includes="*.zip" erroronmissingdir="false" />
</path>
<sequential>
<unzip src="@{file.zip}" dest="${site.dir}" overwrite="true"/>
Expand All @@ -73,14 +73,14 @@

<echo> Copying ${resource.dir} files into ${j2s.dir} </echo>
<copy todir="${j2s.dir}">
<fileset dir="${resource.dir}">
<fileset dir="${resource.dir}" erroronmissingdir="false" >
<include name="**"/>
</fileset>
</copy>

<echo> Copying ${site-resource.dir} files into ${site.dir} </echo>
<copy todir="${site.dir}">
<fileset dir="${site-resource.dir}">
<fileset dir="${site-resource.dir}" erroronmissingdir="false" >
<include name="**"/>
</fileset>
</copy>
Expand Down
Binary file modified sources/net.sf.j2s.core/dist/swingjs/SwingJS-site.zip
Binary file not shown.
Binary file modified sources/net.sf.j2s.core/dist/swingjs/net.sf.j2s.core.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20191008173421
20191020181703
Binary file not shown.
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.4/net.sf.j2s.core.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/ver/3.2.4/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20191008173421
20191020181703
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,45 @@ class Java2ScriptCompiler {
private Map<String, String> htMethodsCalled;
private List<String> lstMethodsDeclared;

private final static String J2S_COMPILER_STATUS = "j2s.compiler.status";
private final static String J2S_COMPILER_STATUS_ENABLE = "enable";
private final static String J2S_COMPILER_STATUS_ENABLED = "enabled";

private static final String J2S_SITE_DIRECTORY = "j2s.site.directory";

/**
* log file name for methods declared
*/
private static final String J2S_LOG_METHODS_DECLARED = "j2s.log.methods.declared";

/**
* log file name for methods called
*/
private static final String J2S_LOG_METHODS_CALLED = "j2s.log.methods.called";

private static final String J2S_LOG_ALL_CALLS = "j2s.log.all.calls";

private static final String J2S_LOG_ALL_CALLS_TRUE = "true";

private static final String J2S_EXCLUDED_PATHS = "j2s.excluded.paths";

private static final String J2S_TESTING = "j2s.testing";

private static final String J2S_TESTING_TRUE = "true";

private static final String J2S_COMPILER_NONQUALIFIED_PACKAGES = "j2s.compiler.nonqualified.packages";

private static final String J2S_COMPILER_NONQUALIFIED_CLASSES = "j2s.compiler.nonqualified.classes";

private static final String J2S_COMPILER_MODE = "j2s.compiler.mode";

private static final String J2S_COMPILER_MODE_DEBUG = "debug";

private static final String J2S_CLASS_REPLACEMENTS = "j2s.class.replacements";

private static final String J2S_TEMPLATE_HTML = "j2s.template.html";


private Properties props;
private String htmlTemplate = null;

Expand Down Expand Up @@ -132,8 +171,8 @@ boolean initializeProject(IJavaProject project, boolean isCompilationParticipant
try {
File j2sFile = new File(projectFolder, J2S_OPTIONS_FILE_NAME);
props.load(new FileInputStream(j2sFile));
String status = getProperty("j2s.compiler.status");
if (!"enable".equals(status) && !"enabled".equals(status)) {
String status = getProperty(J2S_COMPILER_STATUS);
if (!J2S_COMPILER_STATUS_ENABLE.equalsIgnoreCase(status) && !J2S_COMPILER_STATUS_ENABLED.equalsIgnoreCase(status)) {
if (getFileContents(j2sFile).trim().length() == 0) {
writeToFile(j2sFile, getDefaultJ2SFile());
} else {
Expand All @@ -148,7 +187,7 @@ boolean initializeProject(IJavaProject project, boolean isCompilationParticipant
}

File file;
siteFolder = getProperty("j2s.site.directory");
siteFolder = getProperty(J2S_SITE_DIRECTORY);
if (siteFolder == null)
siteFolder = "site";
siteFolder = projectFolder + "/" + siteFolder;
Expand All @@ -159,7 +198,7 @@ boolean initializeProject(IJavaProject project, boolean isCompilationParticipant
// method declarations and invocations are only logged
// when the designated files are deleted prior to building

logDeclared = (isCompilationParticipant && !isCleanBuild ? null : getProperty("j2s.log.methods.declared"));
logDeclared = (isCompilationParticipant && !isCleanBuild ? null : getProperty(J2S_LOG_METHODS_DECLARED));
if (logDeclared != null) {
if (!(file = new File(projectFolder, logDeclared)).exists()) {
lstMethodsDeclared = new ArrayList<String>();
Expand All @@ -169,17 +208,17 @@ boolean initializeProject(IJavaProject project, boolean isCompilationParticipant
}
logAllCalls = false;

logCalled = (isCompilationParticipant && !isCleanBuild ? null : getProperty("j2s.log.methods.called"));
logCalled = (isCompilationParticipant && !isCleanBuild ? null : getProperty(J2S_LOG_METHODS_CALLED));
if (logCalled != null) {
if (!(file = new File(projectFolder, logCalled)).exists()) {
htMethodsCalled = new Hashtable<String, String>();
System.err.println("logging methods called to " + file);
}
logCalled = projectFolder + "/" + logCalled;
logAllCalls = "true".equals(getProperty("j2s.log.all.calls"));
logAllCalls = J2S_LOG_ALL_CALLS_TRUE.equalsIgnoreCase(getProperty(J2S_LOG_ALL_CALLS));
}

excludedPaths = getProperty("j2s.excluded.paths");
excludedPaths = getProperty(J2S_EXCLUDED_PATHS);

lstExcludedPaths = null;

Expand All @@ -193,21 +232,21 @@ boolean initializeProject(IJavaProject project, boolean isCompilationParticipant
lstExcludedPaths = null;
}

testing = "true".equals(getProperty("j2s.testing"));
testing = J2S_TESTING_TRUE.equalsIgnoreCase(getProperty(J2S_TESTING));

String prop = getProperty("j2s.compiler.nonqualified.packages");
String prop = getProperty(J2S_COMPILER_NONQUALIFIED_PACKAGES);
// older version of the name
String nonqualifiedPackages = getProperty("j2s.compiler.nonqualified.classes");
String nonqualifiedPackages = getProperty(J2S_COMPILER_NONQUALIFIED_CLASSES);
nonqualifiedPackages = (prop == null ? "" : prop)
+ (nonqualifiedPackages == null ? "" : (prop == null ? "" : ";") + nonqualifiedPackages);
if (nonqualifiedPackages.length() == 0)
nonqualifiedPackages = null;
// includes @j2sDebug blocks
isDebugging = "debug".equals(getProperty("j2s.compiler.mode"));
isDebugging = J2S_COMPILER_MODE_DEBUG.equalsIgnoreCase(getProperty(J2S_COMPILER_MODE));

String classReplacements = getProperty("j2s.class.replacements");
String classReplacements = getProperty(J2S_CLASS_REPLACEMENTS);

String htmlTemplateFile = getProperty("j2s.template.html");
String htmlTemplateFile = getProperty(J2S_TEMPLATE_HTML);
if (htmlTemplateFile == null)
htmlTemplateFile = "template.html";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
import org.eclipse.jdt.core.dom.WhileStatement;
import org.eclipse.jdt.core.dom.WildcardType;

// BH 2019.10.18 fix for "P$.licationShutdownHooks"
// BH 2019.09.07 adds optimization for lambda methods that do not have finals
// BH 2019.08.29 fix for boxing of binary representation 0b01... (Google Closure Compiler bug)
// BH 2019.05.13 fix for Math.getExponent, ulp, nextDown, nextUp, nextAfter needing qualification
Expand Down Expand Up @@ -1713,8 +1714,11 @@ private void addClassOrInterface(ASTNode node, ITypeBinding binding, List<?> bod
this$0Name0 = this$0Name;
this$0Name = null;
finalShortClassName = getFinalJ2SClassName(
(isLambda ? getMyJavaClassNameLambda(true) : getJavaClassNameQualified(binding)), FINAL_P)
.substring(3);
(isLambda ? getMyJavaClassNameLambda(true) : getJavaClassNameQualified(binding)), FINAL_P);
if (finalShortClassName.startsWith("P$.")) {
// java.lang.x will return x, not P$.x
finalShortClassName = finalShortClassName.substring(3);
}
setClassAndBinding(finalShortClassName, binding);
if (isLambda)
buffer.append("(");
Expand Down Expand Up @@ -4391,8 +4395,9 @@ private String getMyJavaClassNameLambda(boolean andIncrement) {

static String stripJavaLang(String name) {
// shorten java.lang.XXX.YYY but not java.lang.xxx.YYY
return (!name.startsWith("java.lang.") || name.equals("java.lang.Object")
String s = (!name.startsWith("java.lang.") || name.equals("java.lang.Object")
|| name.length() > 10 && !Character.isUpperCase(name.charAt(10)) ? name : name.substring(10));
return s;
}

/**
Expand Down
93 changes: 93 additions & 0 deletions sources/net.sf.j2s.java.core/build-site.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0"?>
<!--
BH 2018.08.12

- requires tools/ant-contrib.jar

- creates the site/ directory if it does not exist
- unzip libjs/*.zip into site/swingjs/j2s
- unzips swingjs/SwingJS-site.zip into site/
- copies non-java resources from resources/ into site/swingjs/j2s

-->

<project name="swingjs-project" default="tosite" basedir="."
xmlns:if="ant:if"
xmlns:unless="ant:unless">

<target name="tosite">

<!-- input directories -->

<!-- location of ant-contrib.jar -->
<property name="tools.dir" value = "tools" />

<!-- SwingjS_site zip file (could be varied if versioning is needed)
<property name="swingjs.zip" value="swingjs/SwingJS-site.zip" />
-->

<!-- location of third-party jar contents as precompiled zipped .js files to copy to site/ -->
<property name="libjs.dir" value="libjs" />

<!-- non-Java resources to copy to site/swingjs/j2s -->
<property name="resource.dir" value="resources" />

<!-- non-Java resources to copy to site/ -->
<property name="site-resource.dir" value="site-resources" />

<!-- output directories -->

<property name="site.dir" value="site" />
<property name="j2s.dir" value="${site.dir}/swingjs/j2s" />

<!-- <for ...> construct needs ant-contrib.jar -->
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${tools.dir}/ant-contrib.jar" />
</classpath>
</taskdef>

<!-- unzip all libjs zip files into site

all zip files placed in libjs will be processed

-->

<for param="file.zip">
<path>
<fileset dir="${libjs.dir}" erroronmissingdir="false" includes="*.zip"/>
</path>
<sequential>
<unzip src="@{file.zip}" dest="${site.dir}" overwrite="true"/>
</sequential>
</for>

<!-- unzip SwingJS-site.zip

not in net.sf.j2s

<unzip src="${swingjs.zip}" dest="${site.dir}/" overwrite="true"/>
-->


<!-- transfer resources -->

<echo> Copying ${resource.dir} files into ${j2s.dir} </echo>
<copy todir="${j2s.dir}">
<fileset dir="${resource.dir}" erroronmissingdir="false" >
<include name="**"/>
</fileset>
</copy>

<echo> Copying ${site-resource.dir} files into ${site.dir} </echo>
<copy todir="${site.dir}">
<fileset dir="${site-resource.dir}" erroronmissingdir="false" >
<include name="**"/>
</fileset>
</copy>


</target>


</project>
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
4 changes: 3 additions & 1 deletion sources/net.sf.j2s.java.core/doc/Differences.txt
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,9 @@ System.exit(0) does not stop all processes
------------------------------------------

Although System.ext(int) has been implemented in JavaScript, it just closes the
frames. It may not stop all "threads." So don't rely on that.
frames, stops all pending javax.swing.Timer objects in the queue, and runs any
threads added using Runtime.getRuntime().addShutdownHook(Thread).
It may not stop all "threads." So don't rely on that.
Applications are responsible for shutting down prior to executing System.exit(0).


Expand Down
6 changes: 6 additions & 0 deletions sources/net.sf.j2s.java.core/site-resources/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SwingJS distribution -- site-resources directory

This directory can be used to hold non-Java files that your program
needs to run -- data files, for instance. Files in it will be copied to
the site/ directory by build-site.xml.

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html>
<head>
<title>SwingJS test GoodByeWorld2</title>
<meta charset="utf-8" />
<script src="swingjs/swingjs2.js"></script>
<script>
if (!self.SwingJS)alert('swingjs2.js was not found. It needs to be in swingjs folder in the same directory as ' + document.location.href)
Info1 = {
code: "test.GoodByeWorld2",
main: null,
core: "NONE",
width: 300,
height: 300,
serverURL: 'http://chemapps.stolaf.edu/jmol/jsmol/php/jsmol.php',
j2sPath: 'swingjs/j2s',
console:'sysoutdiv',
allowjavascript: true
}
Info = {
code: "test.GoodByeWorld2",
main: null,
core: "NONE",
width: 300,
height: 300,
serverURL: 'http://chemapps.stolaf.edu/jmol/jsmol/php/jsmol.php',
j2sPath: 'swingjs/j2s',
console:'sysoutdiv',
allowjavascript: true
}
</script>
</head>
<body>
<table><tr><td>
<script>
SwingJS.getApplet('testApplet1', Info)
</script>
</td><td>
<script>
SwingJS.getApplet('testApplet2', Info)
</script>
</td></tr></table>
<div style="position:absolute;left:900px;top:30px;width:600px;height:700px;">
<div id=sysoutdiv style="border:1px solid green;width:100%;height:95%;overflow:auto"></div>
This is System.out. <a href="javascript:testApplet1._clearConsole()">clear it</a>
</div>
</body>
</html>
37 changes: 37 additions & 0 deletions sources/net.sf.j2s.java.core/site-resources/_Test_Dialog2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html>
<head>
<title>SwingJS test Test_Dialog</title>
<meta charset="utf-8" />
<script src="swingjs/swingjs2.js"></script>
<script>
if (!self.SwingJS)alert('swingjs2.js was not found. It needs to be in swingjs folder in the same directory as ' + document.location.href)
Info = {
code: null,
main: "test.Test_Dialog",
core: "NONE",
width: 850,
height: 550,
serverURL: 'http://chemapps.stolaf.edu/jmol/jsmol/php/jsmol.php',
j2sPath: 'swingjs/j2s',
console:'sysoutdiv',
allowjavascript: true
}
</script>
</head>
<body>
<table><tr><td>
<script>
SwingJS.getApplet('testApplet1', Info)
</script>
</td></tr><tr><td>
<script>
SwingJS.getApplet('testApplet2', Info)
</script>
</td></tr></table>
<div style="position:absolute;left:900px;top:30px;width:600px;height:700px;">
<div id=sysoutdiv style="border:1px solid green;width:100%;height:95%;overflow:auto"></div>
This is System.out. <a href="javascript:testApplet1._clearConsole()">clear it</a>
</div>
</body>
</html>
Loading