Thanks to visit codestin.com
Credit goes to github.com

Skip to content

transpiler lambda expressions; various minor SwingJS issues #177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Aug 7, 2020
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
ddaba2b
Cleaning up HttpClient v2.
warownia1 Jun 26, 2020
83101b7
Rename methods dealing with request form parts and update docs.
warownia1 Jul 3, 2020
5132606
Merge remote-tracking branch 'upstream/hanson1' into hanson1
warownia1 Jul 7, 2020
d991938
Merge pull request #173 from warownia1/hanson1
BobHanson Jul 28, 2020
a3cd353
HttpClient update
Jul 28, 2020
5b2463a
File, FileSystem isDirectory() fix
Jul 29, 2020
9c046b5
test for combo box popup name from jc.name
Jul 29, 2020
941244c
asset skips test for /TEMP/
Jul 31, 2020
04e16c5
j2sMenu back to correct JSeparator look
Jul 31, 2020
e86ef96
JFileDialog multi-select broken
Jul 31, 2020
3ddaed4
JSeparator CSS fix
Jul 31, 2020
a66666c
jQuery fix for no :has selector
Jul 31, 2020
e698479
JSMenuUI fix for position:absolute lost
Jul 31, 2020
f0ac8ef
back to thin-line separator
Jul 31, 2020
a5144dc
SwingJS-site.zip update
Jul 31, 2020
e41fe46
JTable backgrounds restored
Aug 2, 2020
25ecbd2
Transpiler 3.2.9.v1o Java8 lambda expression fix
Aug 2, 2020
781ee58
Assets fix for missing resource
Aug 7, 2020
cf2f895
JSTableUI fix for removed rows or columns
Aug 7, 2020
d20fa9d
adds (singular style) DOMNode.setStyle
Aug 7, 2020
083df6d
JViewport removing unncessary myClip
Aug 7, 2020
0c88387
Transpiler fix
Aug 7, 2020
960a424
SwingJS fix for Character.valueOf cache
Aug 7, 2020
d36d1a4
DOMNode.setStyle
Aug 7, 2020
f88c919
adds more tests to TableDemo
Aug 7, 2020
745a443
addtional Character and Boolean tests
Aug 7, 2020
6c4086f
SwingJS-site update
Aug 7, 2020
f63071c
Merge pull request #176 from BobHanson/hanson1
BobHanson Aug 7, 2020
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
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 @@
20200728062204
20200807063741
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.9/SwingJS-site.zip
Binary file not shown.
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.9/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.9/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20200728062204
20200807063741
3 changes: 3 additions & 0 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 @@ -31,6 +31,9 @@ public class CorePlugin extends Plugin {
// j2sApplet.js and also (Bob only) update.bat, update-clean.bat


// BH 2020.08.03 -- 3.2.9-v1p fix for boxing boolean should be Boolean.valueOf$, not new Boolean
// BH 2020.08.01 -- 3.2.9-v1o fix for lambda expressions too static
// BH 2020.07.08 -- 3.2.9-v1n fix for try with resources and adds option varOrLet
// BH 2020.07.04 -- 3.2.9.v1m fix for X.super.y() in anonymous class
// BH 2020.06.22 -- 3.2.9.v1k fix for varargs not proper qualified arrays
// BH 2020.06.17 -- 3.2.9-v1j fix for functional interface this::privateMethod
Expand Down
74 changes: 41 additions & 33 deletions sources/net.sf.j2s.core/src/net/sf/j2s/core/Java2ScriptVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@

// TODO: superclass inheritance for JAXB XmlAccessorType

//BH 2020.08.03 -- 3.2.9-v1p fix for boxing boolean should be Boolean.valueOf$, not new Boolean
//BH 2020.08.01 -- 3.2.9-v1o fix for lambda expressions too static
//BH 2020.07.08 -- 3.2.9-v1n fix for try with resources and adds option varOrLet
//BH 2020.07.04 -- 3.2.9-v1m fix for X.super.y() in anonymous class
//BH 2020.06.22 -- 3.2.9-v1k fix for varargs not proper qualified arrays
Expand Down Expand Up @@ -654,6 +656,8 @@ int getPrimitiveDefaultType(Code code) {
*/
private boolean[] package_haveStaticArgsReversal = new boolean[] {false};

private int b$count;

private void addApplication() {
if (apps == null)
apps = new ArrayList<String>();
Expand Down Expand Up @@ -1054,6 +1058,8 @@ private String processLocalInstance(ASTNode node, ASTNode anonymousClassDeclarat
// instantiation, so we need to cache the final string "{m:m,b:b,...}" at
// creation time and recover it here.

int b$count0 = b$count;

// String finals;
boolean isStatic = true;
if (localType != REALLY_LOCAL_CLASS) {
Expand Down Expand Up @@ -1092,7 +1098,9 @@ private String processLocalInstance(ASTNode node, ASTNode anonymousClassDeclarat

String key = binding.getKey();
Set<IVariableBinding> set = package_htClassKeyToVisitedFinalVars.get(key);
return (set == null || set.isEmpty() ? anonName : null);
boolean canBeReused = (set == null || set.isEmpty()
&& b$count == b$count0);
return (canBeReused ? anonName : null);
}

/**
Expand Down Expand Up @@ -4804,6 +4812,7 @@ private String getClassNameAndDot(ASTNode node, ITypeBinding declaringClass, boo
* @return "this" + .qualifier
*/
private String getSyntheticReference(String className) {
b$count++;
return "this" + (className.equals("java.lang.Object") || className.equals("Object") ? ""
//: className.equals(this$0Name) ? ".this$0"
: ".b$['" + getFinalJ2SClassName(className, FINAL_RAW) + "']");
Expand All @@ -4827,10 +4836,17 @@ private boolean appendBoxingNode(ASTNode element, boolean toCharCode) {
ITypeBinding typeBinding = exp.resolveTypeBinding();
if (typeBinding.isPrimitive()) {
String name = typeBinding.getName();
name = (name.equals("char") ? "Character"
: name.equals("int") ? "Integer"
: Character.toUpperCase(name.charAt(0)) + name.substring(1));
buffer.append("new " + name + "(");
String t = getJSTypeCode(name);
switch (name) {
case "char":
name = "Character";break;
case "int":
name = "Integer";break;
default:
name = Character.toUpperCase(name.charAt(0)) + name.substring(1);
break;
}
buffer.append(name + ".valueOf$" + t + "(");
element.accept(this);
buffer.append(")");
return true;
Expand Down Expand Up @@ -5673,48 +5689,40 @@ private String j2sGetParamCode(ITypeBinding binding) {
// as well.
// NOTE: These are the same as standard Java Spec, with the exception of
// Short, which is "H" instead of "S"
name = getJSTypeCode(name);
if (arrays != null) {
arrays = arrays.replaceAll("\\[\\]", "A");
name += arrays;
}
return name;
}

switch (name) {
private String getJSTypeCode(String className) {
switch (className) {
case "boolean":
name = "Z";
break;
return "Z";
case "byte":
name = "B";
break;
return "B";
case "char":
name = "C";
break;
return "C";
case "double":
name = "D";
break;
return "D";
case "float":
name = "F";
break;
return "F";
case "int":
name = "I";
break;
return "I";
case "long":
name = "J";
break;
return "J";
case "short":
name = "H"; // differs from Java Spec so we can use S for String
break;
return "H"; // differs from Java Spec so we can use S for String
case "java.lang.Object":
case "Object":
name = "O";
break;
return "O";
case "java.lang.String":
name = "S";
break;
return "S";
default:
name = stripJavaLang(NameMapper.checkClassReplacement(name)).replace('.', '_');
break;
return stripJavaLang(NameMapper.checkClassReplacement(className)).replace('.', '_');
}
if (arrays != null) {
arrays = arrays.replaceAll("\\[\\]", "A");
name += arrays;
}
return name;
}

/**
Expand Down
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
164 changes: 85 additions & 79 deletions sources/net.sf.j2s.java.core/src/java/io/File.java
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,9 @@ public boolean canWrite() {
}

/**
*
* SwingJS note: All directories are considered to exist.
*
* Tests whether the file or directory denoted by this abstract pathname
* exists.
*
Expand All @@ -785,6 +788,9 @@ public boolean exists() {
}

/**
* SwingJS note: The only way we can check if something is a directory is if
* its path is the same as its prefix length. That is, if it ends with "/".
*
* Tests whether the file denoted by this abstract pathname is a
* directory.
*
Expand Down Expand Up @@ -1085,85 +1091,85 @@ public File[] listFiles() {
}
return fs;
}
//
// /**
// * Returns an array of abstract pathnames denoting the files and
// * directories in the directory denoted by this abstract pathname that
// * satisfy the specified filter. The behavior of this method is the same
// * as that of the {@link #listFiles()} method, except that the pathnames in
// * the returned array must satisfy the filter. If the given {@code filter}
// * is {@code null} then all pathnames are accepted. Otherwise, a pathname
// * satisfies the filter if and only if the value {@code true} results when
// * the {@link FilenameFilter#accept
// * FilenameFilter.accept(File,&nbsp;String)} method of the filter is
// * invoked on this abstract pathname and the name of a file or directory in
// * the directory that it denotes.
// *
// * @param filter
// * A filename filter
// *
// * @return An array of abstract pathnames denoting the files and
// * directories in the directory denoted by this abstract pathname.
// * The array will be empty if the directory is empty. Returns
// * {@code null} if this abstract pathname does not denote a
// * directory, or if an I/O error occurs.
// *
// * @throws SecurityException
// * If a security manager exists and its {@link
// * SecurityManager#checkRead(String)} method denies read access to
// * the directory
// *
// * @since 1.2
// */
// public File[] listFiles(FilenameFilter filter) {
// String ss[] = list();
// if (ss == null) return null;
// ArrayList<File> files = new ArrayList<File>();
// for (String s : ss)
// if ((filter == null) || filter.accept(this, s))
// files.add(new File(s, this));
// return files.toArray(new File[files.size()]);
// }
//
// /**
// * Returns an array of abstract pathnames denoting the files and
// * directories in the directory denoted by this abstract pathname that
// * satisfy the specified filter. The behavior of this method is the same
// * as that of the {@link #listFiles()} method, except that the pathnames in
// * the returned array must satisfy the filter. If the given {@code filter}
// * is {@code null} then all pathnames are accepted. Otherwise, a pathname
// * satisfies the filter if and only if the value {@code true} results when
// * the {@link FileFilter#accept FileFilter.accept(File)} method of the
// * filter is invoked on the pathname.
// *
// * @param filter
// * A file filter
// *
// * @return An array of abstract pathnames denoting the files and
// * directories in the directory denoted by this abstract pathname.
// * The array will be empty if the directory is empty. Returns
// * {@code null} if this abstract pathname does not denote a
// * directory, or if an I/O error occurs.
// *
// * @throws SecurityException
// * If a security manager exists and its {@link
// * SecurityManager#checkRead(String)} method denies read access to
// * the directory
// *
// * @since 1.2
// */
// public File[] listFiles(FileFilter filter) {
// String ss[] = list();
// if (ss == null) return null;
// ArrayList<File> files = new ArrayList<File>();
// for (String s : ss) {
// File f = new File(s, this);
// if ((filter == null) || filter.accept(f))
// files.add(f);
// }
// return files.toArray(new File[files.size()]);
// }
//

/**
* Returns an array of abstract pathnames denoting the files and
* directories in the directory denoted by this abstract pathname that
* satisfy the specified filter. The behavior of this method is the same
* as that of the {@link #listFiles()} method, except that the pathnames in
* the returned array must satisfy the filter. If the given {@code filter}
* is {@code null} then all pathnames are accepted. Otherwise, a pathname
* satisfies the filter if and only if the value {@code true} results when
* the {@link FilenameFilter#accept
* FilenameFilter.accept(File,&nbsp;String)} method of the filter is
* invoked on this abstract pathname and the name of a file or directory in
* the directory that it denotes.
*
* @param filter
* A filename filter
*
* @return An array of abstract pathnames denoting the files and
* directories in the directory denoted by this abstract pathname.
* The array will be empty if the directory is empty. Returns
* {@code null} if this abstract pathname does not denote a
* directory, or if an I/O error occurs.
*
* @throws SecurityException
* If a security manager exists and its {@link
* SecurityManager#checkRead(String)} method denies read access to
* the directory
*
* @since 1.2
*/
public File[] listFiles(FilenameFilter filter) {
String ss[] = list();
if (ss == null) return null;
ArrayList<File> files = new ArrayList<File>();
for (String s : ss)
if ((filter == null) || filter.accept(this, s))
files.add(new File(s, this));
return files.toArray(new File[files.size()]);
}

/**
* Returns an array of abstract pathnames denoting the files and
* directories in the directory denoted by this abstract pathname that
* satisfy the specified filter. The behavior of this method is the same
* as that of the {@link #listFiles()} method, except that the pathnames in
* the returned array must satisfy the filter. If the given {@code filter}
* is {@code null} then all pathnames are accepted. Otherwise, a pathname
* satisfies the filter if and only if the value {@code true} results when
* the {@link FileFilter#accept FileFilter.accept(File)} method of the
* filter is invoked on the pathname.
*
* @param filter
* A file filter
*
* @return An array of abstract pathnames denoting the files and
* directories in the directory denoted by this abstract pathname.
* The array will be empty if the directory is empty. Returns
* {@code null} if this abstract pathname does not denote a
* directory, or if an I/O error occurs.
*
* @throws SecurityException
* If a security manager exists and its {@link
* SecurityManager#checkRead(String)} method denies read access to
* the directory
*
* @since 1.2
*/
public File[] listFiles(FileFilter filter) {
String ss[] = list();
if (ss == null) return null;
ArrayList<File> files = new ArrayList<File>();
for (String s : ss) {
File f = new File(s, this);
if ((filter == null) || filter.accept(f))
files.add(f);
}
return files.toArray(new File[files.size()]);
}

/**
* Creates the directory named by this abstract pathname.
*
Expand Down
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.java.core/src/java/io/FileSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private static byte[] _getTempFileBytes(File file) {

boolean _isDir(File file) {
// only an approximation. avoiding xxxx: here completely
return (file.秘bytes == null && _isValid(file) && (file.getPrefixLength() == file.path.length() || !_exists(file)));
return (file.秘bytes == null && _isValid(file) && file.getPrefixLength() == file.path.length());
}

/**
Expand Down
Loading