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

Skip to content

Commit a61045b

Browse files
authored
Merge pull request #174 from BobHanson/hanson1
java.util.concurrent.CompletableFuture and Unsafe field fix
2 parents 8fa97aa + d750ccb commit a61045b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+3708
-3337
lines changed
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-
20200625205024
1+
20200713172416
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-
20200625205024
1+
20200713172416

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class CorePlugin extends Plugin {
3131
// j2sApplet.js and also (Bob only) update.bat, update-clean.bat
3232

3333

34+
// BH 2020.07.04 -- 3.2.9.v1m fix for X.super.y() in anonymous class
3435
// BH 2020.06.22 -- 3.2.9.v1k fix for varargs not proper qualified arrays
3536
// BH 2020.06.17 -- 3.2.9-v1j fix for functional interface this::privateMethod
3637
// BH 2020.05.01 -- 3.2.9-v1i fix for nested lambda methods

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

Lines changed: 97 additions & 74 deletions
Large diffs are not rendered by default.
Binary file not shown.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
We are using the 2015 closure compiler because it does not completely mangle
2+
FOR loops and does not have the 10K $jscomp header. For example:
3+
4+
for (; start < hi; start++) {
5+
let pivot=a[start];
6+
let left=lo;
7+
let right=start;
8+
...
9+
10+
in the newer compiler is converted to:
11+
12+
for(var n={};a<b;
13+
n={$jscomp$loop$prop$left$287:n.$jscomp$loop$prop$left$287,
14+
$jscomp$loop$prop$right$288:n.$jscomp$loop$prop$right$288},a++){
15+
var e=c[a];
16+
n.$jscomp$loop$prop$left$287=d;
17+
n.$jscomp$loop$prop$right$288=a;
18+
...
19+
20+
so every time through the loop n is recreated?
21+
22+
I don't get it.
23+
24+
Binary file not shown.
Binary file not shown.
Binary file not shown.

sources/net.sf.j2s.java.core/src/java/applet/JSApplet.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ public class JSApplet extends JSPanel {
8282
* @since 1.4
8383
*/
8484
public JSApplet() {
85+
秘winOrApplet = true;
8586

86-
// if (GraphicsEnvironment.isHeadless()) {
87+
// if (GraphicsEnvironment.isHeadless()) {
8788
// throw new HeadlessException();
8889
// }
8990
}

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

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -972,8 +972,6 @@ public synchronized DropTarget getDropTarget() {
972972

973973
public GraphicsConfiguration graphicsConfig;
974974

975-
protected boolean isWindow;
976-
977975
/**
978976
* Gets the <code>GraphicsConfiguration</code> associated with this
979977
* <code>Component</code>. If the <code>Component</code> has not been assigned a
@@ -1546,7 +1544,7 @@ public void hide() {
15461544
}
15471545
}
15481546
Container parent = this.parent;
1549-
if (!isWindow && parent != null) {
1547+
if (parent != null && !((JSComponent) this).秘winOrApplet) {
15501548
parent.invalidate();
15511549
}
15521550
// }
@@ -2129,12 +2127,7 @@ public void reshape(int x, int y, int width, int height) {
21292127
}
21302128

21312129
private void repaintParentIfNeeded(int oldX, int oldY, int oldWidth, int oldHeight) {
2132-
if (parent != null && peer instanceof LightweightPeer && isShowing()) {
2133-
// Have the parent redraw the area this component occupied.
2134-
parent.repaint(oldX, oldY, oldWidth, oldHeight);
2135-
// Have the parent redraw the area this component *now* occupies.
2136-
((JSComponent)this).秘repaint();
2137-
}
2130+
((JSComponent)this).秘repaintParentIfNeeded(oldX, oldY, oldWidth, oldHeight);
21382131
}
21392132

21402133
/**
@@ -6704,8 +6697,9 @@ final boolean requestFocusHelper(boolean temporary, boolean focusedWindowChangeA
67046697
}
67056698

67066699
public boolean isWindowOrJSApplet() {
6707-
// SwingJS treating embedded applet as window here
6708-
return this instanceof Window || this instanceof JSApplet;
6700+
return ((JSComponent) this).秘winOrApplet;
6701+
// // SwingJS treating embedded applet as window here
6702+
// return this instanceof Window || this instanceof JSApplet;
67096703
}
67106704

67116705
public boolean isJ2SWindowButNotJInternalFrame() {

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

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
import sun.awt.SunGraphicsCallback;
5252
import swingjs.JSFrameViewer;
5353
import swingjs.JSMouse;
54-
import swingjs.plaf.JSComponentUI;
5554

5655

5756
/**
@@ -364,16 +363,9 @@ final Component[] getComponents_NoClientCode() {
364363
* @see LayoutManager
365364
* @since JDK1.1
366365
*/
367-
public Insets getInsets() {
368-
// Panel, ScrollPane, and Window only
369-
return (peer instanceof ContainerPeer ? this.秘getInsetsC() : NULL_INSETS);
370-
}
371-
372-
public Insets 秘getInsetsC() {
373-
// in SwingJS, we do not clone. Everything is a ContainerPeer.
374-
// it is inconsistent with other classes that this would need cloning.
375-
Insets i = (peer == null ? null : ((ContainerPeer) peer).getInsets());
376-
return (i == null ? NULL_INSETS : i);
366+
@Override
367+
public Insets getInsets() {
368+
return super.getInsets();
377369
}
378370

379371
@Deprecated
@@ -765,15 +757,15 @@ public void setComponentZOrder(Component comp, int index) {
765757
}
766758
}
767759

768-
/**
769-
* Traverses the tree of components and reparents children heavyweight component
770-
* to new heavyweight parent.
771-
* @since 1.5
772-
*/
773-
@SuppressWarnings("deprecation")
774-
private void reparentTraverse(ContainerPeer parentPeer, Container child) {
775-
// JSComponentUI.reparent is not implemented. It just gets tainted.
776-
}
760+
// /**
761+
// * Traverses the tree of components and reparents children heavyweight component
762+
// * to new heavyweight parent.
763+
// * @since 1.5
764+
// */
765+
// @SuppressWarnings("deprecation")
766+
// private void reparentTraverse(ContainerPeer parentPeer, Container child) {
767+
// // JSComponentUI.reparent is not implemented. It just gets tainted.
768+
// }
777769
// checkTreeLock();
778770
//
779771
// for (int i = 0; i < child.getComponentCount(); i++) {

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

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ public interface A2SWrappedComponent {
112112

113113
public String 秘htmlName;
114114

115+
protected boolean 秘winOrApplet;
116+
115117
protected int 秘num;
116118
private static int 秘incr;
117119
private Insets 秘tempInsets;
@@ -242,7 +244,15 @@ public Graphics getGraphics() {
242244
if (width == 0 || height == 0 || !isVisible())
243245
return null;
244246
Graphics g;
245-
if (秘frameViewer != null) {
247+
// this was 秘frameViewer != null, but that
248+
// fails for paintImmediately, because all components
249+
// have a reference to FrameViewer now, and so the
250+
// offset was not being applied. The special case for
251+
// ContentPane adds its insets. parent == null is a
252+
// proxy for Applet or Window since only they can be
253+
// here and not have a parent.
254+
if (秘isRootPane || 秘winOrApplet || 秘isContentPane) {
255+
// this next call adds the necessary transform.
246256
g = 秘frameViewer.getGraphics().create();
247257
if (秘isContentPane) {
248258
if (秘tempInsets == null)
@@ -824,4 +834,29 @@ public static enum ModalExclusionType {
824834
TOOLKIT_EXCLUDE
825835
}
826836

837+
838+
839+
public Insets getInsets() {
840+
// Panel, ScrollPane, and Window only
841+
return 秘getInsets();
842+
}
843+
844+
public Insets 秘getInsets() {
845+
// in SwingJS, we do not clone. Everything is a ContainerPeer.
846+
// it is inconsistent with other classes that this would need cloning.
847+
Insets i = (ui == null ? null : 秘getUI().getInsets());
848+
return (i == null ? Container.NULL_INSETS : i);
849+
}
850+
851+
public void 秘repaintParentIfNeeded(int oldX, int oldY, int oldWidth, int oldHeight) {
852+
if (parent != null && peer instanceof LightweightPeer && isShowing()) {
853+
// Have the parent redraw the area this component occupied.
854+
// Have the parent redraw the area this component *now* occupies.
855+
if (秘getUI().allowPaintedBackground && 秘paintsSelf()) {
856+
parent.repaint(oldX, oldY, oldWidth, oldHeight);
857+
秘repaint();
858+
}
859+
}
860+
}
861+
827862
}

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ public class JSFrame extends Window {
383383
*
384384
*/
385385
public JSFrame() {
386-
initTitleGC(null, null);
386+
this(null, null);
387387
}
388388

389389
/**
@@ -404,7 +404,7 @@ public JSFrame() {
404404
*
405405
*/
406406
public JSFrame(GraphicsConfiguration gc) {
407-
initTitleGC(null, gc);
407+
this(null, gc);
408408
}
409409

410410
/**
@@ -420,7 +420,7 @@ public JSFrame(GraphicsConfiguration gc) {
420420
*
421421
*/
422422
public JSFrame(String title) {
423-
initTitleGC(title, null);
423+
this(title, null);
424424
}
425425

426426
/**
@@ -449,14 +449,10 @@ public JSFrame(String title) {
449449
*
450450
*/
451451
public JSFrame(String title, GraphicsConfiguration gc) {
452-
initTitleGC(title, gc);
452+
super(gc);
453+
this.title = (title == null ? "" : title);
453454
}
454455

455-
protected void initTitleGC(String title, GraphicsConfiguration gc) {
456-
this.title = (title == null ? "" : title);
457-
initWinGC(null, gc); // Window
458-
}
459-
460456
/**
461457
* Construct a name for this component. Called by getName() when the
462458
* name is null.

0 commit comments

Comments
 (0)