Skip to content

Commit 232c114

Browse files
committed
new transpiler v 3.2.9_v1f Fixes (Boolean ? ...) not unboxing, minor
fixes - Avoids $I$(n) need for Boolean and java.util.Date - Adds Date.parse(String) - Corrects ui.getMaximumSize for JTextPane, JTextArea, and JEditorPane - initial "" for JSHtmlHelper.html - removes dependency on Dialog class for Window
1 parent e2256a2 commit 232c114

File tree

19 files changed

+201
-70
lines changed

19 files changed

+201
-70
lines changed
-3.26 KB
Binary file not shown.
6 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20200404111034
1+
20200405214840
-3.26 KB
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20200404111034
1+
20200405214840

sources/net.sf.j2s.core/src/net/sf/j2s/core/CorePlugin.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public class CorePlugin extends Plugin {
3030
// if you change the x.x.x number, be sure to also indicate that in
3131
// j2sApplet.js and also (Bob only) update.bat, update-clean.bat
3232

33+
34+
// BH 2020.04.05 -- 3.2.9-v1f (Boolean ? ...) not unboxed
3335
// BH 2020.03.21 -- 3.2.9-v1e better v1c
3436
// BH 2020.03.20 -- 3.2.9-v1d proper check for new String("x") == "x" (should be false), but new integer(3) == 3 (true)
3537
// BH 2020.03.20 -- 3.2.9-v1c more efficient static call from 3.2.9-v1a

sources/net.sf.j2s.core/src/net/sf/j2s/core/Java2ScriptVisitor.java

Lines changed: 70 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135

136136
// TODO: superclass inheritance for JAXB XmlAccessorType
137137

138+
//BH 2020.04.05 -- 3.2.9-v1f (Boolean ? ...) not unboxed
138139
//BH 2020.03.21 -- 3.2.9-v1e better v1c
139140
//BH 2020.03.20 -- 3.2.9-v1d proper check for new String("x") == "x" (should be false), but new integer(3) == 3 (true)
140141
//BH 2020.03.20 -- 3.2.9-v1c more efficient static call from 3.2.9-v1a
@@ -860,46 +861,46 @@ private void addConstructor(ITypeBinding javaClass,
860861
buffer.append(")");
861862
}
862863

863-
/**
864-
* 3.2.9.v1a
865-
*
866-
* Static method invocations must process parameters before initializing the method's class
867-
* if any parameter either calls a method or defines a static variable. We do this by changing
868-
*
869-
* $I$(3).xxxx(x,y,z)
870-
*
871-
* to
872-
*
873-
* (function(a,b){b.apply(null,a)})([x,y,z],$I$(3).xxxx)
874-
*
875-
* In addition, for constructors, Clazz.new_ needs to have the parameters as the first
876-
* parameter and the constructor method as the second parameter:
877-
*
878-
* Clazz.new_([args],constr)
879-
*
880-
* The method invocation has not been closed at this point.
881-
*
882-
* @param pt start of method name
883-
* @param pt1 end of method name
884-
*/
885-
private void checkStaticParams(int pt, int pt1, boolean isConstructor) {
886-
String args;
887-
// must switch from Clazz.new_($I$(3).xxxx,[x,y,z] to Clazz.new([x,y,z],$I$(3).xxxx
888-
// ............................^pt........^pt1
889-
// must switch from $I$(3).xxxx(x,y,z to (function(a,f){return f.apply(null,a)})([x,y,z],$I$(3).xxxx
890-
// .................^pt........^pt1
891-
if (pt1 == pt
892-
|| buffer.charAt(pt) != '$'
893-
|| (args = buffer.substring(pt1 + 1)).indexOf("(") < 0 && args.indexOf("=") < 0)
894-
return;
895-
String f = buffer.substring(pt, pt1);
896-
buffer.setLength(pt);
897-
if (!isConstructor) {
898-
args = "(function(a,f){return f.apply(null,a)})([" + args + "]";
899-
}
900-
buffer.append(args).append(",").append(f);
901-
}
902-
864+
// /**
865+
// * 3.2.9.v1a
866+
// *
867+
// * Static method invocations must process parameters before initializing the method's class
868+
// * if any parameter either calls a method or defines a static variable. We do this by changing
869+
// *
870+
// * $I$(3).xxxx(x,y,z)
871+
// *
872+
// * to
873+
// *
874+
// * (function(a,b){b.apply(null,a)})([x,y,z],$I$(3).xxxx)
875+
// *
876+
// * In addition, for constructors, Clazz.new_ needs to have the parameters as the first
877+
// * parameter and the constructor method as the second parameter:
878+
// *
879+
// * Clazz.new_([args],constr)
880+
// *
881+
// * The method invocation has not been closed at this point.
882+
// *
883+
// * @param pt start of method name
884+
// * @param pt1 end of method name
885+
// */
886+
// private void checkStaticParams(int pt, int pt1, boolean isConstructor) {
887+
// String args;
888+
// // must switch from Clazz.new_($I$(3).xxxx,[x,y,z] to Clazz.new([x,y,z],$I$(3).xxxx
889+
// // ............................^pt........^pt1
890+
// // must switch from $I$(3).xxxx(x,y,z to (function(a,f){return f.apply(null,a)})([x,y,z],$I$(3).xxxx
891+
// // .................^pt........^pt1
892+
// if (pt1 == pt
893+
// || buffer.charAt(pt) != '$'
894+
// || (args = buffer.substring(pt1 + 1)).indexOf("(") < 0 && args.indexOf("=") < 0)
895+
// return;
896+
// String f = buffer.substring(pt, pt1);
897+
// buffer.setLength(pt);
898+
// if (!isConstructor) {
899+
// args = "(function(a,f){return f.apply(null,a)})([" + args + "]";
900+
// }
901+
// buffer.append(args).append(",").append(f);
902+
// }
903+
//
903904

904905
/**
905906
* 3.2.9.v1c
@@ -3458,7 +3459,10 @@ public boolean visit(ConditionalExpression node) {
34583459
ITypeBinding binding = node.resolveTypeBinding();
34593460
Expression expThen = node.getThenExpression();
34603461
Expression expElse = node.getElseExpression();
3461-
node.getExpression().accept(this);
3462+
Expression exp = node.getExpression();
3463+
exp.accept(this);
3464+
if (exp.resolveUnboxing())
3465+
buffer.append(".booleanValue$()");
34623466
buffer.append(" ? ");
34633467
addExpressionAsTargetType(expThen, binding, "e", null);
34643468
buffer.append(" : ");
@@ -6507,12 +6511,31 @@ static String getPrimitiveTYPE(String name) {
65076511
return type.substring(0, type.indexOf(","));
65086512
}
65096513

6510-
private final static String[] knownClasses = new String[] { "java.lang.Object", "java.lang.Class",
6511-
"java.lang.String", "java.lang.Byte", "java.lang.Character", "java.lang.Short", "java.lang.Long",
6512-
"java.lang.Integer", "java.lang.Float", "java.lang.Double", "java.io.Serializable",
6513-
"java.lang.Iterable", "java.lang.CharSequence", "java.lang.Cloneable", "java.lang.Comparable",
6514-
"java.lang.Runnable", "java.lang.System", "java.lang.ClassLoader", "java.lang.Math",
6515-
"java.lang.Number" };
6514+
private final static String[] knownClasses = new String[] {
6515+
"java.lang.Object",
6516+
"java.lang.Class",
6517+
"java.lang.String",
6518+
"java.lang.Number",
6519+
"java.lang.Byte",
6520+
"java.lang.Character",
6521+
"java.lang.Short",
6522+
"java.lang.Long",
6523+
"java.lang.Integer",
6524+
"java.lang.Float",
6525+
"java.lang.Double",
6526+
"java.lang.Boolean",
6527+
"java.lang.Iterable",
6528+
"java.lang.CharSequence",
6529+
"java.lang.Cloneable",
6530+
"java.lang.Comparable",
6531+
"java.lang.Runnable",
6532+
"java.lang.System",
6533+
"java.lang.Throwable",
6534+
"java.lang.ClassLoader",
6535+
"java.lang.Math",
6536+
"java.io.Serializable",
6537+
"java.util.Date"
6538+
};
65166539
private final static Set<String> knownClassHash = new HashSet<String>();
65176540
static {
65186541
for (int i = knownClasses.length; --i >= 0;)
-3.26 KB
Binary file not shown.

sources/net.sf.j2s.java.core/src/java/awt/JSComponent.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,4 +760,44 @@ protected boolean canPaint() {
760760

761761

762762

763+
/**
764+
*
765+
* SwingJS copied here from Dialog so that it is not necessary to load that AWT class.
766+
*
767+
* Any top-level window can be marked not to be blocked by modal
768+
* dialogs. This is called "modal exclusion". This enum specifies
769+
* the possible modal exclusion types.
770+
*
771+
* @see Window#getModalExclusionType
772+
* @see Window#setModalExclusionType
773+
* @see Toolkit#isModalExclusionTypeSupported
774+
*
775+
* @since 1.6
776+
*/
777+
public static enum ModalExclusionType {
778+
/**
779+
* No modal exclusion.
780+
*/
781+
NO_EXCLUDE,
782+
/**
783+
* <code>APPLICATION_EXCLUDE</code> indicates that a top-level window
784+
* won't be blocked by any application-modal dialogs. Also, it isn't
785+
* blocked by document-modal dialogs from outside of its child hierarchy.
786+
*/
787+
APPLICATION_EXCLUDE,
788+
/**
789+
* <code>TOOLKIT_EXCLUDE</code> indicates that a top-level window
790+
* won't be blocked by application-modal or toolkit-modal dialogs. Also,
791+
* it isn't blocked by document-modal dialogs from outside of its
792+
* child hierarchy.
793+
* The "toolkitModality" <code>AWTPermission</code> must be granted
794+
* for this exclusion. If an exclusion property is being changed to
795+
* <code>TOOLKIT_EXCLUDE</code> and this permission is not granted, a
796+
* <code>SecurityEcxeption</code> will be thrown, and the exclusion
797+
* property will be left unchanged.
798+
*/
799+
TOOLKIT_EXCLUDE
800+
}
801+
802+
763803
}

0 commit comments

Comments
 (0)