Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 31 additions & 0 deletions sources/net.sf.j2s.core/dist/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,37 @@ This is the main README file for the Java2Script/SwingJS distribution

https://github.com/BobHanson/java2script/blob/master/sources/net.sf.j2s.core/dist/README.txt

8/14/2018 Bob Hanson hansonr@stolaf.edu

- allows for no-package applets and applications (which is quite common in the Java applet world).

- totally refactored, streamlined Java-to-JavaScript class name conversion, including the "j2s/_" (single underscore) package, which contains (originally) package-less applets and applications. All Java2ScriptVisitor "getFinal..." methods return JavaScript-ready names that are intended for immediate appending to the output buffer. Prior to that moment, all class names are maintained as their Java values.

- more efficient anonymous class creation (including lambda methods, constructors, and expressions).

- full support for method-local named classes.

- full, efficient support for default interface methods.

- fully qualified methods [ excluding Math.* and *.toString() ], so no conflict with any standard JavaScript objects.

- bullet-proof "final or effectively final" variables.

- strongly anonymous-function scoped for "private" methods.

- corrects several issues with java.util.function.* and java.util.stream.*.

- adds ?j2sverbose option (former standard logging all class loading), with the default being "quiet" mode, which gives no indication of file loading. (Also settable as J2S._quiet = [true|false]

- adds hooks into Clazz object loading, allowing page intervention just after Clazz itself has been loaded, but the core files have not been loaded, and also just after core files have been loaded. This could be useful for customization of the loading process -- for example, dynamically settable core file configuration.

- adds System.getProperty("user.home"), which defaults to https://./ (which isn't a standard protocol, but is passed through the Java system and interpreted in JavaScript as the document base).

- reorganizes java2script project files for better version control.

- adds {project}/resources/ and {project}/libjs as standard places for non-Java resources and zip-equivalents of JAR files that are automatically copied into the {project}/site directory.


8/12/2018 Bob Hanson hansonr@stolaf.edu

The dist/dropins folder has been renamed dist/swingjs
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 @@
20180814211809
20180816081255
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.2/SwingJS-site.zip
Binary file not shown.
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.2/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.2/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20180814211809
20180816081255
10 changes: 5 additions & 5 deletions sources/net.sf.j2s.core/src/net/sf/j2s/core/CorePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public class CorePlugin extends Plugin {
*
*/
public static String VERSION = "3.2.2.04";

// 3.1.1 last Zhou Renjian unqualified name version
// 3.2.1.01 original SwingJS version through 2017 adds $-signatures for methods
// 3.2.2.02 adds $-qualified names for all methods
// 3.2.2.04 2018.08.15 fixing Java->JavaScript "getFinal" code for class names.
// 3.2.2.04 adds support for window-level applets, such as JmolApplet
// 3.2.2.03 adds Java 8 function and stream
// 3.2.2.04 adds support for window-level applets, such as JmolApplet
// 3.2.2.02 adds $-qualified names for all methods
// 3.2.1.01 original SwingJS version through 2017 adds $-signatures for methods
// 3.1.1 last Zhou Renjian unqualified name version
/**
* The constructor.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ public boolean visit(ClassInstanceCreation node) {

private void addConstructor(Type type, IMethodBinding constructorMethodBinding, List<?> arguments,
int lambdaArity) {
String javaClassName = getClassJavaNameForClass(type);
String javaClassName = getClassJavaNameForType(type);
if ("java.lang.Object".equals(javaClassName)) {
buffer.append(" Clazz.new_()");
return;
Expand Down Expand Up @@ -603,19 +603,19 @@ private void openNew(String javaClassName, String anonJavaName, IMethodBinding c
* @param type
* @return
*/
private String getClassJavaNameForClass(Type type) {
private String getClassJavaNameForType(Type type) {
if (type instanceof QualifiedType) {
QualifiedType qualType = (QualifiedType) type;
return getClassJavaNameForClass(qualType.getQualifier()) + "." + qualType.getName().getIdentifier();
return getClassJavaNameForType(qualType.getQualifier()) + "." + qualType.getName().getIdentifier();
}
// if (type instanceof NameQualifiedType) {
// NameQualifiedType nType = (NameQualifiedType) type;
// return getClassJavaNameForClass(nType.getQualifier()) + "." + nType.getName().getIdentifier();
// }
if (type instanceof ArrayType)
return getClassJavaNameForClass(((ArrayType) type).getElementType());
return getClassJavaNameForType(((ArrayType) type).getElementType());
if (type instanceof ParameterizedType)
return getClassJavaNameForClass(((ParameterizedType) type).getType());
return getClassJavaNameForType(((ParameterizedType) type).getType());
if (type instanceof SimpleType) {
ITypeBinding binding = ((SimpleType) type).resolveBinding();
return getJavaClassNameQualified(binding);
Expand Down Expand Up @@ -1515,7 +1515,7 @@ public boolean visit(TryStatement node) {
}
buffer.append(haveType ? " || " : "if (");
buffer.append("Clazz.exceptionOf(" + catchEName + ",\"");
type.accept(this);
buffer.append(getFinalJ2SClassName(getClassJavaNameForType(type), FINAL_RAW));
buffer.append("\")");
haveType = true;
}
Expand Down
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
6 changes: 6 additions & 0 deletions sources/net.sf.j2s.java.core/src/test/Test_Format.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ public static void main(String[] args) {

String s;

s = String.format("%s %d", "testing", 3);
assert(s.equals("testing 3"));

assert(String.format("%s %d-%d", "testing", 3, 4).equals("testing 3-4"));


s = test(100 * Math.pow(10, -6), 2);
System.out.println(s);
assert s.equals("prec=2 0.00 0.00010 1.00e-04");
Expand Down
70 changes: 39 additions & 31 deletions sources/net.sf.j2s.java.core/srcjs/js/j2sClazz.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// TODO: CharacterSequence does not implement Java 8 default methods chars() or codePoints()
// It is possible that these might be loaded dynamically.

// BH 8/16/2018 3.2.2.04 fixes Character.toTitleCase$C, [Integer,Long,Short,Byte].toString(i,radix)
// BH 8/13/2018 3.2.2.04 $finals to $finals$ -- basically variables are $xxx, methods are xxx$, and special values are $xxx$
// BH 8/12/2018 3.2.2 adding J2S.onClazzLoaded hook for Clazz loaded
// BH 8/11/2018 3.2.2 Clazz.newLambda removed
Expand Down Expand Up @@ -98,7 +99,7 @@ window["j2s.clazzloaded"] = true;
_debugging: false,
_loadcore: true,
_nooutput: 0,
_VERSION: "3.2.2.03",
_VERSION_R: "3.2.2.05",
_VERSION_T: "unknown",
};

Expand Down Expand Up @@ -3477,14 +3478,15 @@ var decorateAsNumber = function (clazz, qClazzName, type, PARAMCODE) {

decorateAsNumber(Integer, "Integer", "int", "I");

Integer.toString=Integer.toString$I=Integer.prototype.toString=function(){
if(arguments.length!=0){
return "" + arguments[0];
}
if(this===Integer){
return "class java.lang.Integer";
}
return "" + this.valueOf();
Integer.toString=Integer.toString$I=Integer.toString$I$I=Integer.prototype.toString=function(i,radix){
switch(arguments.length) {
case 2:
return i.toString(radix);
case 1:
return "" +i;
case 0:
return (this===Integer ? "class java.lang.Integer" : ""+this.valueOf());
}
};

m$(Integer, ["c$", "c$$S", "c$$I"], function(v){
Expand Down Expand Up @@ -3668,13 +3670,15 @@ if (typeof arguments[0] != "object")this.c$(arguments[0]);
});

decorateAsNumber(Long, "Long", "long", "L");
Long.toString=Long.toString$J=Long.prototype.toString=function(){
if(arguments.length!=0){
return""+arguments[0];
}else if(this===Long){
return"class java.lang.Long";
}
return""+this.valueOf();
Long.toString=Long.toString$J=Long.toString$J$I = Long.prototype.toString=function(i, radix){
switch(arguments.length) {
case 2:
return i.toString(radix);
case 1:
return "" +i;
case 0:
return (this===Long ? "class java.lang.Long" : ""+this.valueOf());
}
};

m$(Long, ["c$", "c$$S", "c$$J"], function(v){
Expand Down Expand Up @@ -3742,13 +3746,15 @@ function (v,radix) {
this.valueOf = function () {return v;};
}, 1);

Short.toString = Short.prototype.toString = function () {
if (arguments.length != 0) {
return "" + arguments[0];
} else if (this === Short) {
return "class java.lang.Short"; // Short.class.toString
}
return "" + this.valueOf();
Short.toString = Short.toString$H = Short.toString$H$I = Short.prototype.toString = function (i,radix) {
switch(arguments.length) {
case 2:
return i.toString(radix);
case 1:
return "" +i;
case 0:
return (this===Short ? "class java.lang.Short" : ""+this.valueOf());
}
};

Short.MIN_VALUE = Short.prototype.MIN_VALUE = -32768;
Expand Down Expand Up @@ -3804,13 +3810,15 @@ this.valueOf=function(){return v;};
this.byteValue = function(){return v};
}, 1);

Byte.toString=Byte.toString$B=Byte.prototype.toString=function(){
if(arguments.length!=0){
return""+arguments[0];
}else if(this===Byte){
return"class java.lang.Byte";
}
return""+this.valueOf();
Byte.toString=Byte.toString$B=Byte.toString$B$I=Byte.prototype.toString=function(i,radix){
switch(arguments.length) {
case 2:
return i.toString(radix);
case 1:
return "" +i;
case 0:
return (this===Byte ? "class java.lang.Byte" : ""+this.valueOf());
}
};

Byte.serialVersionUID=Byte.prototype.serialVersionUID=-7183698231559129828;
Expand Down Expand Up @@ -4788,7 +4796,7 @@ return(""+c).toLowerCase().charAt(0);
}, 1);
m$(C$,"toTitleCase$C",
function(c){
return Character.toUpperCase(c);
return Character.toUpperCase$C(c);
}, 1);
m$(C$,"toUpperCase$C",
function(c){
Expand Down
68 changes: 38 additions & 30 deletions sources/net.sf.j2s.java.core/srcjs/swingjs2.js
Original file line number Diff line number Diff line change
Expand Up @@ -13462,6 +13462,7 @@ if (!J2S._version)
// TODO: CharacterSequence does not implement Java 8 default methods chars() or codePoints()
// It is possible that these might be loaded dynamically.

// BH 8/16/2018 3.2.2.04 fixes Character.toTitleCase$C, [Integer,Long,Short,Byte].toString(i,radix)
// BH 8/13/2018 3.2.2.04 $finals to $finals$ -- basically variables are $xxx, methods are xxx$, and special values are $xxx$
// BH 8/12/2018 3.2.2 adding J2S.onClazzLoaded hook for Clazz loaded
// BH 8/11/2018 3.2.2 Clazz.newLambda removed
Expand Down Expand Up @@ -13550,7 +13551,7 @@ window["j2s.clazzloaded"] = true;
_debugging: false,
_loadcore: true,
_nooutput: 0,
_VERSION: "3.2.2.03",
_VERSION_R: "3.2.2.05",
_VERSION_T: "unknown",
};

Expand Down Expand Up @@ -16929,14 +16930,15 @@ var decorateAsNumber = function (clazz, qClazzName, type, PARAMCODE) {

decorateAsNumber(Integer, "Integer", "int", "I");

Integer.toString=Integer.toString$I=Integer.prototype.toString=function(){
if(arguments.length!=0){
return "" + arguments[0];
}
if(this===Integer){
return "class java.lang.Integer";
}
return "" + this.valueOf();
Integer.toString=Integer.toString$I=Integer.toString$I$I=Integer.prototype.toString=function(i,radix){
switch(arguments.length) {
case 2:
return i.toString(radix);
case 1:
return "" +i;
case 0:
return (this===Integer ? "class java.lang.Integer" : ""+this.valueOf());
}
};

m$(Integer, ["c$", "c$$S", "c$$I"], function(v){
Expand Down Expand Up @@ -17120,13 +17122,15 @@ if (typeof arguments[0] != "object")this.c$(arguments[0]);
});

decorateAsNumber(Long, "Long", "long", "L");
Long.toString=Long.toString$J=Long.prototype.toString=function(){
if(arguments.length!=0){
return""+arguments[0];
}else if(this===Long){
return"class java.lang.Long";
}
return""+this.valueOf();
Long.toString=Long.toString$J=Long.toString$J$I = Long.prototype.toString=function(i, radix){
switch(arguments.length) {
case 2:
return i.toString(radix);
case 1:
return "" +i;
case 0:
return (this===Long ? "class java.lang.Long" : ""+this.valueOf());
}
};

m$(Long, ["c$", "c$$S", "c$$J"], function(v){
Expand Down Expand Up @@ -17194,13 +17198,15 @@ function (v,radix) {
this.valueOf = function () {return v;};
}, 1);

Short.toString = Short.prototype.toString = function () {
if (arguments.length != 0) {
return "" + arguments[0];
} else if (this === Short) {
return "class java.lang.Short"; // Short.class.toString
}
return "" + this.valueOf();
Short.toString = Short.toString$H = Short.toString$H$I = Short.prototype.toString = function (i,radix) {
switch(arguments.length) {
case 2:
return i.toString(radix);
case 1:
return "" +i;
case 0:
return (this===Short ? "class java.lang.Short" : ""+this.valueOf());
}
};

Short.MIN_VALUE = Short.prototype.MIN_VALUE = -32768;
Expand Down Expand Up @@ -17256,13 +17262,15 @@ this.valueOf=function(){return v;};
this.byteValue = function(){return v};
}, 1);

Byte.toString=Byte.toString$B=Byte.prototype.toString=function(){
if(arguments.length!=0){
return""+arguments[0];
}else if(this===Byte){
return"class java.lang.Byte";
}
return""+this.valueOf();
Byte.toString=Byte.toString$B=Byte.toString$B$I=Byte.prototype.toString=function(i,radix){
switch(arguments.length) {
case 2:
return i.toString(radix);
case 1:
return "" +i;
case 0:
return (this===Byte ? "class java.lang.Byte" : ""+this.valueOf());
}
};

Byte.serialVersionUID=Byte.prototype.serialVersionUID=-7183698231559129828;
Expand Down