From af802cb54114616dc74217ac91a65ecdb15d144f Mon Sep 17 00:00:00 2001
From: Sergey Bylokhov
Date: Mon, 25 Apr 2016 19:14:30 +0300
Subject: [PATCH 001/120] 7124381: DragSourceListener.dragDropEnd() never been
called on completion of dnd operation
Reviewed-by: yan, ssadetsky
---
.../dnd/Button2DragTest/Button2DragTest.html | 45 ----------
.../dnd/Button2DragTest/Button2DragTest.java | 82 +++++++++----------
2 files changed, 41 insertions(+), 86 deletions(-)
delete mode 100644 jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.html
diff --git a/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.html b/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.html
deleted file mode 100644
index 91dcf4f413d..00000000000
--- a/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.html
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
-
-
-
-
-
-Button2DragTest
Bug ID: 4955110
-
- This is an AUTOMATIC test, simply wait for completion
-
-
-
-
diff --git a/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.java b/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.java
index 33bb5058706..c5045ed7fa7 100644
--- a/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.java
+++ b/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -21,45 +21,52 @@
* questions.
*/
-/*
- test
- @bug 4955110
- @summary tests that a drag ends on button2 release
- @author Alexander.Gerasimov area=dnd
- @library ../../regtesthelpers
- @build Util
- @run applet/othervm Button2DragTest.html
-*/
+import java.awt.Frame;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.datatransfer.StringSelection;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.DragGestureListener;
+import java.awt.dnd.DragSource;
+import java.awt.dnd.DragSourceAdapter;
+import java.awt.dnd.DragSourceDropEvent;
+import java.awt.dnd.DragSourceListener;
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.DropTargetAdapter;
+import java.awt.dnd.DropTargetDropEvent;
+import java.awt.event.InputEvent;
-
-/**
- * Button2DragTest.java
- *
- * summary: tests that DragSourceDragEvent.getDropAction() accords to its new spec
- * (does not depend on the user drop action)
- *
- */
-
-import java.applet.Applet;
-import java.awt.*;
-import java.awt.event.*;
-import java.awt.datatransfer.*;
-import java.awt.dnd.*;
import test.java.awt.regtesthelpers.Util;
-
-public class Button2DragTest extends Applet {
+/**
+ * @test
+ * @bug 4955110
+ * @summary tests that DragSourceDragEvent.getDropAction() accords to its new
+ * spec (does not depend on the user drop action)
+ * @library ../../regtesthelpers
+ * @build Util
+ * @run main/othervm Button2DragTest
+ * @author Alexander.Gerasimov area=dnd
+ */
+public final class Button2DragTest {
private volatile boolean dropSuccess;
- private Frame frame;
+ private static Frame frame;
+ public static void main(final String[] args) {
+ Button2DragTest test = new Button2DragTest();
+ try {
+ test.run();
+ } finally {
+ if (frame != null) {
+ frame.dispose();
+ }
+ }
+ }
- public void init() {
- // Set up the environment -- set the layout manager, add
- // buttons, etc.
- setLayout(new BorderLayout());
-
+ public void run() {
frame = new Frame();
final DragSourceListener dragSourceListener = new DragSourceAdapter() {
@@ -84,20 +91,13 @@ public class Button2DragTest extends Applet {
}
};
new DropTarget(frame, dropTargetListener);
- }
-
-
- public void start() {
- //Get things going. Request focus, set size, et cetera
- setSize(200,200);
- setVisible(true);
- validate();
//What would normally go into main() will probably go here.
//Use System.out.println for diagnostic messages that you want
//to read after the test is done.
-
+ frame.setUndecorated(true);
frame.setBounds(100, 100, 200, 200);
+ frame.setLocationRelativeTo(null);
frame.setVisible(true);
Robot robot = Util.createRobot();
From 5874c487963e3aaf423b2c43cd18b8f1a290347e Mon Sep 17 00:00:00 2001
From: Avik Niyogi
Date: Wed, 27 Apr 2016 12:08:37 +0400
Subject: [PATCH 002/120] 8152492: [macosx swing] double key event actions when
using Mac menubar
Reviewed-by: serb, mhalder, alexsch
---
.../native/libawt_lwawt/awt/CMenuItem.m | 113 ++++++------------
.../ActionListenerCalledTwiceTest.java | 33 +++--
2 files changed, 59 insertions(+), 87 deletions(-)
diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m
index 28e4f386d78..e6b7e21bccb 100644
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m
@@ -25,7 +25,6 @@
#import
#include
-
#import "CMenuItem.h"
#import "CMenu.h"
#import "AWTEvent.h"
@@ -64,42 +63,6 @@
- (BOOL) worksWhenModal {
return YES;
}
-// This is a method written using Carbon framework methods to remove
-// All modifiers including "Shift" modifier.
-// Example 1: Shortcut set is "Command Shift m" returns "m"
-// Example 2: Shortcut set is "Command m" returns "m"
-// Example 3: Shortcut set is "Alt Shift ," returns ","
-
-CFStringRef createStringForKey(CGKeyCode keyCode)
-{
- TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource();
-// currentKeyboard now contains the current input source
- CFDataRef layoutData =
- TISGetInputSourceProperty(currentKeyboard,
- kTISPropertyUnicodeKeyLayoutData);
-// the UNICODE keyLayout is fetched from currentKeyboard in layoutData
- const UCKeyboardLayout *keyboardLayout =
- (const UCKeyboardLayout *)CFDataGetBytePtr(layoutData);
-// A read-only data pointer is fetched from layoutData
- UInt32 keysDown = 0;
- UniChar chars[4];
- UniCharCount realLength;
-
- UCKeyTranslate(keyboardLayout,
- keyCode,
- kUCKeyActionDisplay,
- 0,
- LMGetKbdType(),
- kUCKeyTranslateNoDeadKeysBit,
- &keysDown,
- sizeof(chars) / sizeof(chars[0]),
- &realLength,
- chars);
- CFRelease(currentKeyboard);
-// Converts keyCode, modifier and dead-key state into UNICODE characters
- return CFStringCreateWithCharacters(kCFAllocatorDefault, chars, 1);
-}
-
// Events
- (void)handleAction:(NSMenuItem *)sender {
AWT_ASSERT_APPKIT_THREAD;
@@ -116,35 +79,6 @@ CFStringRef createStringForKey(CGKeyCode keyCode)
// from this "frameless" menu, because there are no active windows. This
// means we have to handle it here.
NSEvent *currEvent = [[NSApplication sharedApplication] currentEvent];
- if ([currEvent type] == NSKeyDown) {
- NSString *menuKey = [sender keyEquivalent];
-// If shortcut is "Command Shift ," the menuKey gets the value ","
-// But [currEvent charactersIgnoringModifiers]; returns "<" and not ","
-// because the charactersIgnoreingModifiers does not ignore "Shift"
-// So a shortcut like "Command Shift m" will return "M" where as the
-// MenuKey will have the value "m". To remove this issue the below
-// createStringForKey is used.
- NSString *eventKey = createStringForKey([currEvent keyCode]);
-
-// Apple uses characters from private Unicode range for some of the
-// keys, so we need to do the same translation here that we do
-// for the regular key down events
- if ([eventKey length] == 1) {
- unichar origChar = [eventKey characterAtIndex:0];
- unichar newChar = NsCharToJavaChar(origChar, 0);
- if (newChar == java_awt_event_KeyEvent_CHAR_UNDEFINED) {
- newChar = origChar;
- }
-
- eventKey = [NSString stringWithCharacters: &newChar length: 1];
- }
-
- NSWindow *keyWindow = [NSApp keyWindow];
- if ([menuKey isEqualToString:eventKey] && keyWindow != nil) {
- return;
- }
- }
-
if (fIsCheckbox) {
static JNF_CLASS_CACHE(jc_CCheckboxMenuItem, "sun/lwawt/macosx/CCheckboxMenuItem");
static JNF_MEMBER_CACHE(jm_ckHandleAction, jc_CCheckboxMenuItem, "handleAction", "(Z)V");
@@ -154,16 +88,47 @@ CFStringRef createStringForKey(CGKeyCode keyCode)
NSInteger state = [sender state];
jboolean newState = (state == NSOnState ? JNI_FALSE : JNI_TRUE);
JNFCallVoidMethod(env, fPeer, jm_ckHandleAction, newState);
- } else {
- static JNF_CLASS_CACHE(jc_CMenuItem, "sun/lwawt/macosx/CMenuItem");
- static JNF_MEMBER_CACHE(jm_handleAction, jc_CMenuItem, "handleAction", "(JI)V"); // AWT_THREADING Safe (event)
-
- NSUInteger modifiers = [currEvent modifierFlags];
- jint javaModifiers = NsKeyModifiersToJavaModifiers(modifiers, NO);
-
- JNFCallVoidMethod(env, fPeer, jm_handleAction, UTC(currEvent), javaModifiers); // AWT_THREADING Safe (event)
+ }
+ else {
+ if ([currEvent type] == NSKeyDown) {
+
+ // Event available through sender variable hence NSApplication
+ // not needed for checking the keyboard input sans the modifier keys
+ // Also, the method used to fetch eventKey earlier would be locale dependent
+ // With earlier implementation, if MenuKey: e EventKey: ा ; if input method
+ // is not U.S. (Devanagari in this case)
+ // With current implementation, EventKey = MenuKey = e irrespective of
+ // input method
+
+ NSString *eventKey = [sender keyEquivalent];
+ // Apple uses characters from private Unicode range for some of the
+ // keys, so we need to do the same translation here that we do
+ // for the regular key down events
+ if ([eventKey length] == 1) {
+ unichar origChar = [eventKey characterAtIndex:0];
+ unichar newChar = NsCharToJavaChar(origChar, 0);
+ if (newChar == java_awt_event_KeyEvent_CHAR_UNDEFINED) {
+ newChar = origChar;
+ }
+ eventKey = [NSString stringWithCharacters: &newChar length: 1];
+ }
+ NSWindow *keyWindow = [NSApp keyWindow];
+ if (keyWindow != nil) {
+ return;
+ }
+ else {
+ static JNF_CLASS_CACHE(jc_CMenuItem, "sun/lwawt/macosx/CMenuItem");
+ static JNF_MEMBER_CACHE(jm_handleAction, jc_CMenuItem, "handleAction", "(JI)V"); // AWT_THREADING Safe (event)
+
+ NSUInteger modifiers = [currEvent modifierFlags];
+ jint javaModifiers = NsKeyModifiersToJavaModifiers(modifiers, NO);
+
+ JNFCallVoidMethod(env, fPeer, jm_handleAction, UTC(currEvent), javaModifiers); // AWT_THREADING Safe (event)
+ }
+ }
}
JNF_COCOA_EXIT(env);
+
}
- (void) setJavaLabel:(NSString *)theLabel shortcut:(NSString *)theKeyEquivalent modifierMask:(jint)modifiers {
diff --git a/jdk/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java b/jdk/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java
index 1a9f42120e2..589bb9b5744 100644
--- a/jdk/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java
+++ b/jdk/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java
@@ -21,23 +21,23 @@
* questions.
*/
-/*
+ /*
* @test
- * @bug 7160951
+ * @bug 7160951 8152492
* @summary [macosx] ActionListener called twice for JMenuItem using ScreenMenuBar
* @author vera.akulova@oracle.com
* @library ../../../../lib/testlibrary
* @build jdk.testlibrary.OSInfo
* @run main ActionListenerCalledTwiceTest
*/
-
import jdk.testlibrary.OSInfo;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ActionListenerCalledTwiceTest {
- static String menuItems[] = { "Item1", "Item2", "Item3", "Item4", "Item5", "Item6" };
+
+ static String menuItems[] = {"Item1", "Item2", "Item3", "Item4", "Item5", "Item6"};
static KeyStroke keyStrokes[] = {
KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.META_MASK),
KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0),
@@ -46,8 +46,10 @@ public class ActionListenerCalledTwiceTest {
KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_MASK),
KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, InputEvent.META_MASK)
};
-
+ static JMenu menu;
+ static JFrame frame;
static volatile int listenerCallCounter = 0;
+
public static void main(String[] args) throws Exception {
if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
@@ -82,33 +84,38 @@ public class ActionListenerCalledTwiceTest {
robot.waitForIdle();
if (listenerCallCounter != 1) {
- throw new Exception("Test failed: ActionListener for " + menuItems[i] +
- " called " + listenerCallCounter + " times instead of 1!");
+ throw new Exception("Test failed: ActionListener for " + menuItems[i]
+ + " called " + listenerCallCounter + " times instead of 1!");
}
listenerCallCounter = 0;
}
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.dispose();
+ }
+ });
}
private static void createAndShowGUI() {
- JMenu menu = new JMenu("Menu");
+ menu = new JMenu("Menu");
for (int i = 0; i < menuItems.length; ++i) {
JMenuItem newItem = new JMenuItem(menuItems[i]);
newItem.setAccelerator(keyStrokes[i]);
newItem.addActionListener(
- new ActionListener(){
- public void actionPerformed(ActionEvent e) {
- listenerCallCounter++;
- }
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ listenerCallCounter++;
}
+ }
);
menu.add(newItem);
}
JMenuBar bar = new JMenuBar();
bar.add(menu);
- JFrame frame = new JFrame("Test");
+ frame = new JFrame("Test");
frame.setJMenuBar(bar);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
From eb3750d326afb8d965fe737ac92c7562010b8aef Mon Sep 17 00:00:00 2001
From: Manajit Halder
Date: Wed, 27 Apr 2016 13:09:58 +0300
Subject: [PATCH 003/120] 8151136: [macosx] According to the description, the
case is failed
Reviewed-by: ssadetsky, aniyogi
---
.../macosx/native/libawt_lwawt/awt/AWTEvent.m | 28 +++++++++++++++----
.../AltGraphModifierTest.java | 13 +++++----
2 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m
index 9b8e370a938..e57074ee74c 100644
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -282,11 +282,19 @@ const nsKeyToJavaModifierTable[] =
//kCGSFlagsMaskAppleLeftAlternateKey,
//kCGSFlagsMaskAppleRightAlternateKey,
58,
- 61,
+ 0,
java_awt_event_InputEvent_ALT_DOWN_MASK,
java_awt_event_InputEvent_ALT_MASK,
java_awt_event_KeyEvent_VK_ALT
},
+ {
+ NSAlternateKeyMask,
+ 0,
+ 61,
+ java_awt_event_InputEvent_ALT_DOWN_MASK | java_awt_event_InputEvent_ALT_GRAPH_DOWN_MASK,
+ java_awt_event_InputEvent_ALT_MASK | java_awt_event_InputEvent_ALT_GRAPH_MASK,
+ java_awt_event_KeyEvent_VK_ALT
+ },
{
NSCommandKeyMask,
//kCGSFlagsMaskAppleLeftCommandKey,
@@ -310,6 +318,8 @@ const nsKeyToJavaModifierTable[] =
{0, 0, 0, 0, 0, 0}
};
+static BOOL leftAltKeyPressed;
+
/*
* Almost all unicode characters just go from NS to Java with no translation.
* For the few exceptions, we handle it here with this small table.
@@ -523,13 +533,17 @@ NsKeyModifiersToJavaKeyInfo(NSUInteger nsFlags, unsigned short eventKeyCode,
// *javaKeyLocation = java_awt_event_KeyEvent_KEY_LOCATION_RIGHT;
//}
if (eventKeyCode == cur->leftKeyCode) {
+ leftAltKeyPressed = YES;
*javaKeyLocation = java_awt_event_KeyEvent_KEY_LOCATION_LEFT;
} else if (eventKeyCode == cur->rightKeyCode) {
*javaKeyLocation = java_awt_event_KeyEvent_KEY_LOCATION_RIGHT;
+ } else if (cur->nsMask == NSAlternateKeyMask) {
+ leftAltKeyPressed = NO;
+ continue;
}
*javaKeyType = (cur->nsMask & nsFlags) ?
- java_awt_event_KeyEvent_KEY_PRESSED :
- java_awt_event_KeyEvent_KEY_RELEASED;
+ java_awt_event_KeyEvent_KEY_PRESSED :
+ java_awt_event_KeyEvent_KEY_RELEASED;
break;
}
}
@@ -545,7 +559,11 @@ jint NsKeyModifiersToJavaModifiers(NSUInteger nsFlags, BOOL isExtMods)
for (cur = nsKeyToJavaModifierTable; cur->nsMask != 0; ++cur) {
if ((cur->nsMask & nsFlags) != 0) {
- javaModifiers |= isExtMods? cur->javaExtMask : cur->javaMask;
+ javaModifiers |= isExtMods ? cur->javaExtMask : cur->javaMask;
+ if (cur->nsMask == NSAlternateKeyMask && leftAltKeyPressed == NO) {
+ continue;
+ }
+ break;
}
}
diff --git a/jdk/test/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java b/jdk/test/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java
index 92dcc214376..00c471ad7f4 100644
--- a/jdk/test/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java
+++ b/jdk/test/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -50,7 +50,7 @@ public class AltGraphModifierTest {
"3. If Alt-Gr key is not present, press Ctrl+Alt keys &",
" perform mouse click on the TestWindow.",
"4. Test will exit by itself with appropriate result.",
- "",
+ " ",
"Linux :-",
"1. Please check if Alt-Gr key is present on keyboard.",
"2. If present, press the Alt-Gr key and perform",
@@ -63,10 +63,11 @@ public class AltGraphModifierTest {
"6. Press Right Alt Key & perform mouse click on the",
" TestWindow",
"7. Test will exit by itself with appropriate result.",
- "",
+ " ",
"Mac :-",
- " Mac fix is under progress, & will be fixed soon.",
- " Please click Fail"
+ "1. Press Right Option key on the keyboard and mouse click",
+ " on the TestWindow",
+ "3. Test will exit by itself with appropriate result.",
};
Sysout.createDialog();
@@ -77,7 +78,7 @@ public class AltGraphModifierTest {
public static void initTestWindow() {
mainFrame = new Frame();
mainFrame.setTitle("TestWindow");
- mainFrame.setSize(300, 200);
+ mainFrame.setBounds(700, 10, 300, 300);
mainFrame.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
From 0a29c9196258f080fa24e7bac2febfbce479e072 Mon Sep 17 00:00:00 2001
From: Alexander Stepanov
Date: Thu, 28 Apr 2016 19:35:09 +0300
Subject: [PATCH 004/120] 8155021: [TEST] create one more inheritance test for
@BeanProperty
Reviewed-by: serb
---
.../AnonymousClassBeanPropertyTest.java | 218 ++-
.../beans/Introspector/BeanPropertyTest.java | 85 +-
.../InheritanceBeanPropertyTest.java | 1281 +++++++++++++++++
3 files changed, 1552 insertions(+), 32 deletions(-)
create mode 100644 jdk/test/java/beans/Introspector/InheritanceBeanPropertyTest.java
diff --git a/jdk/test/java/beans/Introspector/AnonymousClassBeanPropertyTest.java b/jdk/test/java/beans/Introspector/AnonymousClassBeanPropertyTest.java
index a8ec7d49188..b5fc3667b94 100644
--- a/jdk/test/java/beans/Introspector/AnonymousClassBeanPropertyTest.java
+++ b/jdk/test/java/beans/Introspector/AnonymousClassBeanPropertyTest.java
@@ -33,7 +33,7 @@ import java.util.Arrays;
/**
* @test
- * @bug 8132973 8132732 8155013
+ * @bug 8132973 8132732 8155013 8154958
* @summary Some check for BeanProperty annotation
* @author a.stepanov
* @run main AnonymousClassBeanPropertyTest
@@ -62,6 +62,10 @@ public class AnonymousClassBeanPropertyTest {
// ---------- test cases (interfaces) ----------
+ public interface IPublic {
+ double getX();
+ }
+
private interface IGet {
double getX();
}
@@ -113,6 +117,10 @@ public class AnonymousClassBeanPropertyTest {
void setX(double a[]);
}
+ private interface IIs {
+ boolean isX();
+ }
+
// ---------- checks ----------
@@ -124,7 +132,7 @@ public class AnonymousClassBeanPropertyTest {
return ok;
}
- private static boolean checkInfo(Class> c, String what) {
+ private static boolean checkInfo(Class> c, String what, boolean checkVals) {
BeanInfo i;
try { i = Introspector.getBeanInfo(c, Object.class); }
@@ -154,6 +162,8 @@ public class AnonymousClassBeanPropertyTest {
ok &= check("visualUpdate",
(boolean) d.getValue("visualUpdate"), UPDATE);
+ if (!checkVals) { return ok; }
+
Object vals[] = (Object[]) d.getValue("enumerationValues");
if (vals == null) {
System.out.println("null enumerationValues");
@@ -210,8 +220,10 @@ public class AnonymousClassBeanPropertyTest {
(boolean) d.getValue("visualUpdate"), !UPDATE);
Object vals[] = (Object[]) d.getValue("enumerationValues");
- if (vals != null || vals.length > 0) {
- System.out.println("non-empty enumerationValues");
+ if (vals != null && vals.length > 0) {
+ System.out.println("non-empty enumerationValues:");
+ for (Object v: vals) { System.out.print(v.toString()); }
+ System.out.println();
return false;
}
@@ -228,6 +240,31 @@ public class AnonymousClassBeanPropertyTest {
//----------------------------------------------------------------------
+ // TODO: please uncomment/update after 8154958 fix
+ /*
+ IPublic testPublic = new IPublic() {
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ @Override
+ public double getX() { return X; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ };
+ ok = checkInfo(testPublic.getClass(), "IPublic", true);
+ System.out.println("OK = " + ok);
+ passed = passed && ok;
+ */
+
+ //----------------------------------------------------------------------
+
IGet testGet = new IGet() {
@BeanProperty(
description = DESCRIPTION,
@@ -244,7 +281,7 @@ public class AnonymousClassBeanPropertyTest {
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
};
- ok = checkInfo(testGet.getClass(), "IGet");
+ ok = checkInfo(testGet.getClass(), "IGet", true);
System.out.println("OK = " + ok);
passed = passed && ok;
@@ -269,7 +306,7 @@ public class AnonymousClassBeanPropertyTest {
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
};
- ok = checkInfo(testSet.getClass(), "ISet");
+ ok = checkInfo(testSet.getClass(), "ISet", true);
System.out.println("OK = " + ok);
passed = passed && ok;
@@ -294,7 +331,7 @@ public class AnonymousClassBeanPropertyTest {
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
};
- ok = checkInfo(testGetByIndex.getClass(), "IGetByIndex");
+ ok = checkInfo(testGetByIndex.getClass(), "IGetByIndex", true);
System.out.println("OK = " + ok);
passed = passed && ok;
@@ -319,7 +356,7 @@ public class AnonymousClassBeanPropertyTest {
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
};
- ok = checkInfo(testSetByIndex.getClass(), "ISetByIndex");
+ ok = checkInfo(testSetByIndex.getClass(), "ISetByIndex", true);
System.out.println("OK = " + ok);
passed = passed && ok;
@@ -346,7 +383,7 @@ public class AnonymousClassBeanPropertyTest {
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
};
- ok = checkInfo(testGetArray.getClass(), "IGetArray");
+ ok = checkInfo(testGetArray.getClass(), "IGetArray", true);
System.out.println("OK = " + ok);
passed = passed && ok;
*/
@@ -374,7 +411,7 @@ public class AnonymousClassBeanPropertyTest {
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
};
- ok = checkInfo(testSetArray.getClass(), "ISetArray");
+ ok = checkInfo(testSetArray.getClass(), "ISetArray", true);
System.out.println("OK = " + ok);
passed = passed && ok;
*/
@@ -402,7 +439,7 @@ public class AnonymousClassBeanPropertyTest {
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
};
- ok = checkInfo(testGetBoth_1.getClass(), "IGetBoth-1");
+ ok = checkInfo(testGetBoth_1.getClass(), "IGetBoth-1", true);
System.out.println("OK = " + ok);
passed = passed && ok;
@@ -429,7 +466,7 @@ public class AnonymousClassBeanPropertyTest {
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
};
- ok = checkInfo(testGetBoth_2.getClass(), "IGetBoth-2");
+ ok = checkInfo(testGetBoth_2.getClass(), "IGetBoth-2", true);
System.out.println("OK = " + ok);
passed = passed && ok;
*/
@@ -465,11 +502,11 @@ public class AnonymousClassBeanPropertyTest {
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
};
- ok = checkInfo(testGetBoth_3.getClass(), "IGetBoth-3");
+ ok = checkInfo(testGetBoth_3.getClass(), "IGetBoth-3", true);
System.out.println("OK = " + ok);
ok2 = checkAlternativeInfo(testGetBoth_3.getClass(), "IGetBoth-3");
System.out.println("OK = " + ok2);
- passed = passed && ok && ok2;
+ passed = passed && (ok || ok2);
*/
//----------------------------------------------------------------------
@@ -495,7 +532,7 @@ public class AnonymousClassBeanPropertyTest {
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
};
- ok = checkInfo(testSetBoth_1.getClass(), "ISetBoth-1");
+ ok = checkInfo(testSetBoth_1.getClass(), "ISetBoth-1", true);
System.out.println("OK = " + ok);
passed = passed && ok;
@@ -522,7 +559,7 @@ public class AnonymousClassBeanPropertyTest {
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
};
- ok = checkInfo(testSetBoth_2.getClass(), "ISetBoth-2");
+ ok = checkInfo(testSetBoth_2.getClass(), "ISetBoth-2", true);
System.out.println("OK = " + ok);
passed = passed && ok;
*/
@@ -558,11 +595,11 @@ public class AnonymousClassBeanPropertyTest {
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
};
- ok = checkInfo(testSetBoth_3.getClass(), "ISetBoth-3");
+ ok = checkInfo(testSetBoth_3.getClass(), "ISetBoth-3", true);
System.out.println("OK = " + ok);
ok2 = checkAlternativeInfo(testSetBoth_3.getClass(), "ISetBoth-3");
System.out.println("OK = " + ok2);
- passed = passed && ok && ok2;
+ passed = passed && (ok || ok2);
*/
//----------------------------------------------------------------------
@@ -588,7 +625,7 @@ public class AnonymousClassBeanPropertyTest {
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
};
- ok = checkInfo(testGetSet_1.getClass(), "IGetSet-1");
+ ok = checkInfo(testGetSet_1.getClass(), "IGetSet-1", true);
System.out.println("OK = " + ok);
passed = passed && ok;
@@ -614,7 +651,7 @@ public class AnonymousClassBeanPropertyTest {
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
};
- ok = checkInfo(testGetSet_2.getClass(), "IGetSet-2");
+ ok = checkInfo(testGetSet_2.getClass(), "IGetSet-2", true);
System.out.println("OK = " + ok);
passed = passed && ok;
@@ -649,11 +686,11 @@ public class AnonymousClassBeanPropertyTest {
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
};
- ok = checkInfo(testGetSet_3.getClass(), "IGetSet-3");
+ ok = checkInfo(testGetSet_3.getClass(), "IGetSet-3", true);
System.out.println("OK = " + ok);
ok2 = checkAlternativeInfo(testGetSet_3.getClass(), "IGetSet-3");
System.out.println("OK = " + ok2);
- passed = passed && ok && ok2;
+ passed = passed && (ok || ok2);
*/
//----------------------------------------------------------------------
@@ -679,7 +716,7 @@ public class AnonymousClassBeanPropertyTest {
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
};
- ok = checkInfo(testGetSetByIndex_1.getClass(), "IGetSetByIndex-1");
+ ok = checkInfo(testGetSetByIndex_1.getClass(), "IGetSetByIndex-1", true);
System.out.println("OK = " + ok);
passed = passed && ok;
@@ -705,7 +742,7 @@ public class AnonymousClassBeanPropertyTest {
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
};
- ok = checkInfo(testGetSetByIndex_2.getClass(), "IGetSetByIndex-2");
+ ok = checkInfo(testGetSetByIndex_2.getClass(), "IGetSetByIndex-2", true);
System.out.println("OK = " + ok);
passed = passed && ok;
@@ -744,12 +781,12 @@ public class AnonymousClassBeanPropertyTest {
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
};
- ok = checkInfo(testGetSetByIndex_3.getClass(), "IGetSetByIndex-3");
+ ok = checkInfo(testGetSetByIndex_3.getClass(), "IGetSetByIndex-3", true);
System.out.println("OK = " + ok);
ok2 = checkAlternativeInfo(
testGetSetByIndex_3.getClass(), "IGetSetByIndex-3");
System.out.println("OK = " + ok2);
- passed = passed && ok && ok2;
+ passed = passed && (ok || ok2);
*/
//----------------------------------------------------------------------
@@ -781,7 +818,7 @@ public class AnonymousClassBeanPropertyTest {
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
};
- ok = checkInfo(testGetSetBoth_1.getClass(), "IGetSetBoth-1");
+ ok = checkInfo(testGetSetBoth_1.getClass(), "IGetSetBoth-1", true);
System.out.println("OK = " + ok);
passed = passed && ok;
*/
@@ -813,7 +850,7 @@ public class AnonymousClassBeanPropertyTest {
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
};
- ok = checkInfo(testGetSetBoth_2.getClass(), "IGetSetBoth-2");
+ ok = checkInfo(testGetSetBoth_2.getClass(), "IGetSetBoth-2", true);
System.out.println("OK = " + ok);
passed = passed && ok;
*/
@@ -853,14 +890,135 @@ public class AnonymousClassBeanPropertyTest {
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
};
- ok = checkInfo(testGetSetBoth_3.getClass(), "IGetSetBoth-3");
+ ok = checkInfo(testGetSetBoth_3.getClass(), "IGetSetBoth-3", true);
System.out.println("OK = " + ok);
ok2 = checkAlternativeInfo(
testGetSetBoth_3.getClass(), "IGetSetBoth-3");
System.out.println("OK = " + ok2);
- passed = passed && ok && ok2;
+ passed = passed && (ok || ok2);
*/
+ //----------------------------------------------------------------------
+
+ IIs testIs_1 = new IIs() {
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE)
+ @Override
+ public boolean isX() { return false; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ };
+ ok = checkInfo(testIs_1.getClass(), "IIs-1", false);
+ System.out.println("OK = " + ok);
+ passed = passed && ok;
+
+
+ IIs testIs_2 = new IIs() {
+
+ private boolean b;
+
+ @Override
+ public boolean isX() { return b; }
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE)
+ public void setX(boolean v) { b = v; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ };
+ ok = checkInfo(testIs_2.getClass(), "IIs-2", false);
+ System.out.println("OK = " + ok);
+ passed = passed && ok;
+
+
+ IIs testIs_3 = new IIs() {
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE)
+ @Override
+ public boolean isX() { return false; }
+
+ @BeanProperty(
+ description = DESCRIPTION_2,
+ bound = !BOUND,
+ expert = !EXPERT,
+ hidden = !HIDDEN,
+ preferred = !PREFERRED,
+ required = !REQUIRED,
+ visualUpdate = !UPDATE)
+ public boolean getX() { return false; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ };
+ ok = checkInfo(testIs_3.getClass(), "IIs-3", false);
+ System.out.println("OK = " + ok);
+ ok2 = checkAlternativeInfo(testIs_3.getClass(), "IIs-3");
+ System.out.println("OK = " + ok2);
+ passed = passed && (ok || ok2);
+
+ // TODO: please uncomment/update after 8132973 fix
+ /*
+ IIs testIs_4 = new IIs() {
+
+ private boolean b;
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE)
+ @Override
+ public boolean isX() { return b; }
+
+ @BeanProperty(
+ description = DESCRIPTION_2,
+ bound = !BOUND,
+ expert = !EXPERT,
+ hidden = !HIDDEN,
+ preferred = !PREFERRED,
+ required = !REQUIRED,
+ visualUpdate = !UPDATE)
+ public void setX(boolean v) { b = v; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ };
+ ok = checkInfo(testIs_4.getClass(), "IIs-4", false);
+ System.out.println("OK = " + ok);
+ ok2 = checkAlternativeInfo(testIs_4.getClass(), "IIs-4");
+ System.out.println("OK = " + ok2);
+ passed = passed && (ok || ok2);
+ */
+
+
+ //----------------------------------------------------------------------
+
+
if (!passed) { throw new RuntimeException("test failed"); }
System.out.println("\ntest passed");
}
diff --git a/jdk/test/java/beans/Introspector/BeanPropertyTest.java b/jdk/test/java/beans/Introspector/BeanPropertyTest.java
index 6f957074c6e..5e84aaaed4e 100644
--- a/jdk/test/java/beans/Introspector/BeanPropertyTest.java
+++ b/jdk/test/java/beans/Introspector/BeanPropertyTest.java
@@ -33,7 +33,7 @@ import java.util.Arrays;
/**
* @test
- * @bug 8132703 8132163 8132732 8132973 8154756 8132888
+ * @bug 8132703 8132163 8132732 8132973 8154756 8132888 8155103
* @summary Some check for BeanProperty annotation
* @author a.stepanov
* @run main BeanPropertyTest
@@ -853,6 +853,64 @@ public class BeanPropertyTest {
public void removePropertyChangeListener(PropertyChangeListener l) {}
}
+ // JDK-8155103
+ public static enum E {
+
+ ONE,
+ TWO {
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ public void setX(int v) {}
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ };
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ public void setX(int v) {}
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+
+ }
+
+ private static enum EB {
+
+ TRUE(true), FALSE(false);
+
+ private boolean b;
+ private EB(boolean v) { b = v; }
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE)
+ public boolean isTrue() { return true; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+
+ }
+
// ---------- checks ----------
@@ -953,7 +1011,7 @@ public class BeanPropertyTest {
}
private static boolean ignoreVals(Class> c) {
- return (c.equals(Self.class) || c.equals(SelfArr.class));
+ return (c.equals(Self.class) || c.equals(SelfArr.class)) || c.equals(EB.class);
}
@@ -1003,6 +1061,29 @@ public class BeanPropertyTest {
passed = passed && ok;
}
+ // enums
+
+ Class> enumCases[] = {
+
+ // TODO: uncomment/update after 8155103 fix
+ //E.class, E.TWO.getClass(), EB.class
+ };
+
+ int ne = 1;
+ for (Class> c: enumCases) {
+
+ System.out.println("\nEnum-" + ne + ":");
+ ne++;
+
+ BeanInfo i;
+ try { i = Introspector.getBeanInfo(c, Object.class); }
+ catch (IntrospectionException e) { throw new RuntimeException(e); }
+ boolean ok = checkInfo(i, !ignoreVals(c));
+ System.out.println(ok ? "OK" : "NOK");
+ passed = passed && ok;
+ }
+
+
if (!passed) { throw new RuntimeException("test failed"); }
System.out.println("\ntest passed");
}
diff --git a/jdk/test/java/beans/Introspector/InheritanceBeanPropertyTest.java b/jdk/test/java/beans/Introspector/InheritanceBeanPropertyTest.java
new file mode 100644
index 00000000000..e42fa6228f3
--- /dev/null
+++ b/jdk/test/java/beans/Introspector/InheritanceBeanPropertyTest.java
@@ -0,0 +1,1281 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.beans.BeanInfo;
+import java.beans.BeanProperty;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyDescriptor;
+
+import java.util.Arrays;
+
+
+/**
+ * @test
+ * @bug 8132565 8155013
+ * @summary Some inheritance check for BeanProperty annotation
+ * @author a.stepanov
+ * @run main InheritanceBeanPropertyTest
+ */
+
+
+public class InheritanceBeanPropertyTest {
+
+ private final static String DESCRIPTION = "TEST";
+ private final static boolean BOUND = true;
+ private final static boolean EXPERT = false;
+ private final static boolean HIDDEN = true;
+ private final static boolean PREFERRED = false;
+ private final static boolean REQUIRED = true;
+ private final static boolean UPDATE = false;
+
+ private final static double X = java.lang.Math.PI;
+
+ private final static String
+ V_NAME = "java.lang.Math.PI",
+ V_SHORT = "PI",
+ V = Double.toString(X);
+
+ private final static String DESCRIPTION_2 = "XYZ";
+
+
+ // ---------- test cases ----------
+
+ public static class BaseGet {
+
+ private final static String TESTCASE = "base getter";
+
+ public double getX() { return X; }
+ }
+
+ public static class OverloadGet extends BaseGet {
+
+ private final static String TESTCASE = "overload getter";
+
+ private final double x[] = {X, X, X};
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ public double getX(int i) { return x[i]; } // indexed
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ // ----------
+
+ public static class BaseSet {
+
+ private final static String TESTCASE = "base setter";
+
+ double u;
+ public void setX(double v) { u = v; }
+ }
+
+ public static class OverloadSet extends BaseSet {
+
+ private final static String TESTCASE = "overload setter";
+
+ private final double x[] = {X, X, X};
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ public void setX(int i, double v) { x[i] = v; } // indexed
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ // ----------
+
+ public static class BaseIGet {
+
+ protected final double x[] = {X, X, X};
+ public double[] getX() { return x; }
+ }
+
+ public static class OverloadIGet extends BaseIGet {
+
+ private final static String TESTCASE = "overload indexed getter";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ public double getX(int i) { return x[i]; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ // ----------
+
+ public static class BaseISet {
+
+ protected double x[] = {X, X, X};
+ public void setX(double a[]) { x = Arrays.copyOf(a, a.length); }
+ }
+
+ public static class OverloadISet extends BaseISet {
+
+ private final static String TESTCASE = "overload indexed setter";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ public void setX(int i, double v) { x[i] = v; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ // ----------
+
+ public static class BoolGet {
+
+ @BeanProperty(
+ description = DESCRIPTION_2,
+ bound = !BOUND,
+ expert = !EXPERT,
+ hidden = !HIDDEN,
+ preferred = !PREFERRED,
+ required = !REQUIRED,
+ visualUpdate = !UPDATE)
+ public boolean getX() { return false; }
+ }
+
+ public static class BoolGetIs extends BoolGet {
+
+ private final static String TESTCASE = "base boolean getter + is";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE)
+ public boolean isX() { return false; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+ // ----------
+
+ public static class BoolIs {
+
+ @BeanProperty(
+ description = DESCRIPTION_2,
+ bound = !BOUND,
+ expert = !EXPERT,
+ hidden = !HIDDEN,
+ preferred = !PREFERRED,
+ required = !REQUIRED,
+ visualUpdate = !UPDATE)
+ public boolean isX() { return false; }
+ }
+
+ public static class BoolIsGet extends BoolIs {
+
+ private final static String TESTCASE = "base is + boolean getter";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE)
+ public boolean getX() { return false; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ // ----------
+
+ public static class AnnotatedGet {
+
+ private final static String TESTCASE = "annotated super getter";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ public double getX() { return 0.; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ public static class OverrideAnnotatedGet extends AnnotatedGet {
+
+ private final static String TESTCASE = "override annotated getter";
+
+ @Override
+ public double getX() { return X; }
+ }
+
+ // ----------
+
+ public static class AnnotatedIs {
+
+ private final static String TESTCASE = "annotated super is";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ public boolean isX() { return false; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ public static class OverrideAnnotatedIs extends AnnotatedIs {
+
+ private final static String TESTCASE = "override annotated is";
+
+ @Override
+ public boolean isX() { return false; }
+ }
+
+ // ----------
+
+ public static class AnnotatedSet {
+
+ private final static String TESTCASE = "annotated super set";
+
+ protected double x;
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ public void setX(double v) { x = -v; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ public static class OverrideAnnotatedSet extends AnnotatedSet {
+
+ private final static String TESTCASE = "override annotated setter";
+
+ @Override
+ public void setX(double v) { x = v; }
+ }
+
+ // ----------
+
+ public static class AnnotatedGet2 {
+
+ protected double x;
+
+ @BeanProperty(
+ description = DESCRIPTION_2,
+ bound = !BOUND,
+ expert = !EXPERT,
+ hidden = !HIDDEN,
+ preferred = !PREFERRED,
+ required = !REQUIRED,
+ visualUpdate = !UPDATE)
+ public double getX() { return 0.; }
+ }
+
+ public static class OverrideAnnotatedGet2 extends AnnotatedGet2 {
+
+ private final static String TESTCASE = "override annotated getter - 2";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ @Override
+ public double getX() { return X; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ public static class AnnotatedGet2Ext extends AnnotatedGet2 {
+
+ private final static String TESTCASE = "extend annotated getter - 2";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ public void setX(double v) { x = v; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ // ----------
+
+ public static class AnnotatedIs2 {
+
+ protected boolean b = false;
+
+ @BeanProperty(
+ description = DESCRIPTION_2,
+ bound = !BOUND,
+ expert = !EXPERT,
+ hidden = !HIDDEN,
+ preferred = !PREFERRED,
+ required = !REQUIRED,
+ visualUpdate = !UPDATE)
+ public boolean isX() { return false; }
+ }
+
+ public static class OverrideAnnotatedIs2 extends AnnotatedIs2 {
+
+ private final static String TESTCASE = "override annotated is - 2";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE)
+ @Override
+ public boolean isX() { return b; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ public static class AnnotatedIs2Ext extends AnnotatedIs2 {
+
+ private final static String TESTCASE = "extend annotated is - 2";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE)
+ public void setX(boolean v) { b = v; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ // ----------
+
+ public static class AnnotatedSet2 {
+
+ protected double x;
+
+ @BeanProperty(
+ description = DESCRIPTION_2,
+ bound = !BOUND,
+ expert = !EXPERT,
+ hidden = !HIDDEN,
+ preferred = !PREFERRED,
+ required = !REQUIRED,
+ visualUpdate = !UPDATE)
+ public void setX(double v) { x = -v; }
+ }
+
+ public static class OverrideAnnotatedSet2 extends AnnotatedSet2 {
+
+ private final static String TESTCASE = "override annotated setter - 2";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ @Override
+ public void setX(double v) { x = v; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ public static class AnnotatedSet2Ext extends AnnotatedSet2 {
+
+ private final static String TESTCASE = "extend annotated setter - 2";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ public double getX() { return x; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ // ----------
+
+ public abstract static class AbstractGet {
+
+ @BeanProperty(
+ description = DESCRIPTION_2,
+ bound = !BOUND,
+ expert = !EXPERT,
+ hidden = !HIDDEN,
+ preferred = !PREFERRED,
+ required = !REQUIRED,
+ visualUpdate = !UPDATE)
+ public abstract double getX();
+ }
+
+ public static class OverrideAbstractGet extends AbstractGet {
+
+ private final static String TESTCASE =
+ "override abstract annotated getter";
+
+ @Override
+ public double getX() { return X; }
+ }
+
+ public static class OverrideAbstractGet2 extends AbstractGet {
+
+ private final static String TESTCASE =
+ "override abstract annotated getter - 2";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ @Override
+ public double getX() { return X; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ public abstract static class AbstractGetExt extends AbstractGet {
+
+ private final static String TESTCASE =
+ "extend abstract annotated getter";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ public abstract void setX(double v);
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ // ----------
+
+ public abstract static class AbstractIs {
+
+ @BeanProperty(
+ description = DESCRIPTION_2,
+ bound = !BOUND,
+ expert = !EXPERT,
+ hidden = !HIDDEN,
+ preferred = !PREFERRED,
+ required = !REQUIRED,
+ visualUpdate = !UPDATE)
+ public abstract boolean isX();
+ }
+
+ public static class OverrideAbstractIs extends AbstractIs {
+
+ private final static String TESTCASE =
+ "override abstract annotated is";
+
+ @Override
+ public boolean isX() { return true; }
+ }
+
+ public static class OverrideAbstractIs2 extends AbstractIs {
+
+ private final static String TESTCASE =
+ "override abstract annotated is - 2";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE)
+ @Override
+ public boolean isX() { return true; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+
+ public abstract static class AbstractIsExt extends AbstractIs {
+
+ private final static String TESTCASE =
+ "extend abstract annotated is";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE)
+ public abstract boolean getX();
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ // ----------
+
+ public abstract static class AbstractSet {
+
+ @BeanProperty(
+ description = DESCRIPTION_2,
+ bound = !BOUND,
+ expert = !EXPERT,
+ hidden = !HIDDEN,
+ preferred = !PREFERRED,
+ required = !REQUIRED,
+ visualUpdate = !UPDATE)
+ public abstract void setX(double v);
+ }
+
+ public static class OverrideAbstractSet extends AbstractSet {
+
+ private final static String TESTCASE =
+ "override abstract annotated setter";
+
+ private double x;
+
+ @Override
+ public void setX(double v) { x = v; }
+ }
+
+ public static class OverrideAbstractSet2 extends AbstractSet {
+
+ private final static String TESTCASE =
+ "override abstract annotated setter - 2";
+
+ private double x;
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ @Override
+ public void setX(double v) { x = v; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ public abstract static class AbstractSetExt extends AbstractSet {
+
+ private final static String TESTCASE =
+ "extend abstract annotated setter";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ public abstract void setX(double v[]);
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ // ----------
+
+ public static abstract class AbstractGet2 {
+
+ private final static String TESTCASE = "abstract super getter";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ public abstract double getX();
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ public static abstract class AbstractGet2Ext extends AbstractGet2 {
+
+ @BeanProperty(
+ description = DESCRIPTION_2,
+ bound = !BOUND,
+ expert = !EXPERT,
+ hidden = !HIDDEN,
+ preferred = !PREFERRED,
+ required = !REQUIRED,
+ visualUpdate = !UPDATE)
+ public abstract void setX(double a[]);
+ }
+
+ // ----------
+
+ public static interface IGet {
+
+ @BeanProperty(
+ description = DESCRIPTION_2,
+ bound = !BOUND,
+ expert = !EXPERT,
+ hidden = !HIDDEN,
+ preferred = !PREFERRED,
+ required = !REQUIRED,
+ visualUpdate = !UPDATE)
+ double getX();
+ }
+
+ public static class IGetImpl implements IGet {
+
+ private final static String TESTCASE = "implement getter interface";
+
+ @Override
+ public double getX() { return X; }
+ }
+
+ public static class IGetImpl2 implements IGet {
+
+ private final static String TESTCASE = "implement getter interface - 2";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ @Override
+ public double getX() { return X; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ public abstract static class IGetImpl3 implements IGet {
+
+ private final static String TESTCASE = "implement getter interface - 3";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ public abstract void setX(double v);
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ // ----------
+
+ public static interface IIs {
+
+ @BeanProperty(
+ description = DESCRIPTION_2,
+ bound = !BOUND,
+ expert = !EXPERT,
+ hidden = !HIDDEN,
+ preferred = !PREFERRED,
+ required = !REQUIRED,
+ visualUpdate = !UPDATE)
+ public boolean isX();
+ }
+
+ public static class IIsImpl implements IIs {
+
+ private final static String TESTCASE = "implement is interface";
+
+ @Override
+ public boolean isX() { return true; }
+ }
+
+ public static class IIsImpl2 implements IIs {
+
+ private final static String TESTCASE = "implement is interface - 2";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE)
+ @Override
+ public boolean isX() { return true; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ public abstract static class IIsImpl3 implements IIs {
+
+ private final static String TESTCASE = "implement is interface - 3";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE)
+ public abstract void setX(boolean v);
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ // ----------
+
+ public static interface ISet {
+
+ @BeanProperty(
+ description = DESCRIPTION_2,
+ bound = !BOUND,
+ expert = !EXPERT,
+ hidden = !HIDDEN,
+ preferred = !PREFERRED,
+ required = !REQUIRED,
+ visualUpdate = !UPDATE)
+ public void setX(double v);
+ }
+
+ public static class ISetImpl implements ISet {
+
+ private final static String TESTCASE = "implement getter interface";
+
+ private double x;
+
+ @Override
+ public void setX(double v) { x = v; }
+ }
+
+ public static class ISetImpl2 implements ISet {
+
+ private final static String TESTCASE = "implement getter interface - 2";
+
+ private double x;
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ @Override
+ public void setX(double v) { x = v; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ public abstract static class ISetImpl3 implements ISet {
+
+ private final static String TESTCASE = "implement getter interface - 3";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ public abstract double getX();
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ // ----------
+
+ public static interface ISet2 {
+
+ final static String TESTCASE = "super interface - setter";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ public void setX(double v);
+
+ public void addPropertyChangeListener(PropertyChangeListener l);
+ public void removePropertyChangeListener(PropertyChangeListener l);
+ }
+
+ public static class ISet2Impl implements ISet2 {
+
+ private double x;
+
+ @BeanProperty(
+ description = DESCRIPTION_2,
+ bound = !BOUND,
+ expert = !EXPERT,
+ hidden = !HIDDEN,
+ preferred = !PREFERRED,
+ required = !REQUIRED,
+ visualUpdate = !UPDATE)
+ @Override
+ public void setX(double v) { x = v; }
+
+ @Override
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ @Override
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ // ----------
+
+ public static interface IGet2 {
+
+ final static String TESTCASE = "super interface - indexed getter";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ public double[] getX();
+
+ public void addPropertyChangeListener(PropertyChangeListener l);
+ public void removePropertyChangeListener(PropertyChangeListener l);
+ }
+
+ public static class IGet2Impl implements IGet2 {
+
+ @BeanProperty(
+ description = DESCRIPTION_2,
+ bound = !BOUND,
+ expert = !EXPERT,
+ hidden = !HIDDEN,
+ preferred = !PREFERRED,
+ required = !REQUIRED,
+ visualUpdate = !UPDATE)
+ @Override
+ public double[] getX() { return new double[]{X, X}; }
+
+ @Override
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ @Override
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ // ----------
+
+ public static class ProtectedGet {
+
+ @BeanProperty(
+ description = DESCRIPTION_2,
+ bound = !BOUND,
+ expert = !EXPERT,
+ hidden = !HIDDEN,
+ preferred = !PREFERRED,
+ required = !REQUIRED,
+ visualUpdate = !UPDATE)
+ protected double getX() { return 0.; }
+ }
+
+ public static class OverrideProtectedGet extends ProtectedGet {
+
+ final static String TESTCASE = "override protected getter";
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE,
+ enumerationValues = {V_NAME})
+ @Override
+ public double getX() { return X; }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ // ----------
+
+ // static getter - see also JDK-8154938
+ public static class StaticGet {
+
+ @BeanProperty(
+ description = DESCRIPTION_2,
+ bound = !BOUND,
+ expert = !EXPERT,
+ hidden = !HIDDEN,
+ preferred = !PREFERRED,
+ required = !REQUIRED,
+ visualUpdate = !UPDATE)
+ public static double getProp() { return 0.; }
+ }
+
+ public static class HideStaticGet extends StaticGet {
+
+ final static String TESTCASE = "hide static getter";
+
+ public double getX() { return X; } // add to get the "default" info
+ public static double getProp() { return X; }
+ }
+
+ // TODO: if 8154938 is considered to be a real issue,
+ // create one more test case "HideStaticGet2 extends StaticGet" with an
+ // annotated getter and check the correctness of the corresponding bean info
+
+ // ---------- checks ----------
+
+ private static boolean check(String what, boolean v, boolean ref) {
+
+ boolean ok = (v == ref);
+ if (!ok) { System.out.println(
+ "invalid " + what + ": " + v + ", expected: " + ref); }
+ return ok;
+ }
+
+ private static boolean checkInfo(BeanInfo i, boolean ignoreValsCheck) {
+
+ System.out.println("checking info...");
+
+ PropertyDescriptor descriptors[] = i.getPropertyDescriptors();
+ int nd = descriptors.length;
+ if (nd != 1) {
+ System.out.println("invalid number of descriptors: " + nd);
+ return false;
+ }
+
+ PropertyDescriptor d = descriptors[0];
+
+ String descr = d.getShortDescription();
+ boolean ok = descr.equals(DESCRIPTION);
+ if (!ok) { System.out.println("invalid description: " + descr +
+ ", expected: " + DESCRIPTION); }
+
+ ok &= check("isBound", d.isBound(), BOUND);
+ ok &= check("isExpert", d.isExpert(), EXPERT);
+ ok &= check("isHidden", d.isHidden(), HIDDEN);
+ ok &= check("isPreferred", d.isPreferred(), PREFERRED);
+ ok &= check("required", (boolean) d.getValue("required"), REQUIRED);
+ ok &= check("visualUpdate",
+ (boolean) d.getValue("visualUpdate"), UPDATE);
+
+ if (ignoreValsCheck) { return ok; }
+
+ Object vals[] = (Object[]) d.getValue("enumerationValues");
+ if (vals == null) {
+ System.out.println("null enumerationValues");
+ return false;
+ }
+
+ boolean okVals = (
+ (vals.length == 3) &&
+ vals[0].toString().equals(V_SHORT) &&
+ vals[1].toString().equals(V) &&
+ vals[2].toString().equals(V_NAME));
+
+ if (!okVals) { System.out.println("invalid enumerationValues"); }
+
+ return (ok && okVals);
+ }
+
+ private static boolean checkDefault(BeanInfo i) {
+
+ System.out.println("checking default info...");
+
+ PropertyDescriptor descriptors[] = i.getPropertyDescriptors();
+ int nd = descriptors.length;
+ if (nd != 1) {
+ System.out.println("invalid number of descriptors: " + nd);
+ return false;
+ }
+
+ PropertyDescriptor d = descriptors[0];
+
+ String descr = d.getShortDescription();
+ boolean ok = descr.equals("x");
+ if (!ok) { System.out.println("invalid description: " + descr +
+ ", expected: x"); }
+
+ ok &= check("isBound", d.isBound(), false);
+ ok &= check("isExpert", d.isExpert(), false);
+ ok &= check("isHidden", d.isHidden(), false);
+ ok &= check("isPreferred", d.isPreferred(), false);
+ ok &= check("required", (boolean) d.getValue("required"), false);
+ ok &= check("visualUpdate",
+ (boolean) d.getValue("visualUpdate"), false);
+
+ Object vals[] = (Object[]) d.getValue("enumerationValues");
+ if (vals != null && vals.length > 0) {
+ System.out.println("non-empty enumerationValues");
+ ok = false;
+ }
+
+ return ok;
+ }
+
+ // do not check enumerationValues for these classes
+ private static boolean ignoreVals(Class> c) {
+ return (
+ c.equals(BoolGetIs.class) ||
+ c.equals(BoolIsGet.class) ||
+ c.equals(AnnotatedIs.class) ||
+ c.equals(OverrideAnnotatedIs2.class) ||
+ c.equals(AnnotatedIs2Ext.class) ||
+ c.equals(OverrideAbstractIs.class) ||
+ c.equals(OverrideAbstractIs2.class) ||
+ c.equals(AbstractIsExt.class) ||
+ c.equals(OverrideAbstractIs.class) ||
+ c.equals(IIsImpl.class) ||
+ c.equals(IIsImpl2.class) ||
+ c.equals(IIsImpl3.class)
+ );
+ }
+
+ // default property descriptor data are expected for these classes
+ private static boolean isDefault(Class> c) {
+ return (
+ c.equals(OverrideAnnotatedGet.class) ||
+ c.equals(OverrideAnnotatedIs.class ) ||
+ c.equals(OverrideAnnotatedSet.class) ||
+ c.equals(OverrideAbstractGet.class) ||
+ c.equals(OverrideAbstractIs.class) ||
+ c.equals(OverrideAbstractSet.class) ||
+ c.equals(IGetImpl.class) ||
+ c.equals(IIsImpl.class) ||
+ c.equals(ISetImpl.class) ||
+ c.equals(BaseGet.class) ||
+ c.equals(BaseSet.class) ||
+ c.equals(HideStaticGet.class)
+ );
+ }
+
+
+ // ---------- run test ----------
+
+ public static void main(String[] args) throws Exception {
+
+ Class>
+ ic1 = ISet2Impl.class.getInterfaces()[0],
+ ic2 = IGet2Impl.class.getInterfaces()[0];
+
+ Class> cases[] = {
+
+ OverloadGet.class,
+ OverloadGet.class.getSuperclass(),
+ OverloadSet.class,
+ OverloadSet.class.getSuperclass(),
+ OverloadIGet.class,
+ OverloadISet.class,
+
+ // TODO: uncomment/update after 8132565 fix
+ //BoolGetIs.class,
+ //BoolIsGet.class,
+ //OverrideAnnotatedGet.class,
+ //OverrideAnnotatedIs.class,
+ //OverrideAnnotatedSet.class,
+ //OverrideAnnotatedGet2.class,
+ //AnnotatedGet2Ext.class,
+ //OverrideAnnotatedIs2.class
+ //AnnotatedIs2Ext.class,
+ //OverrideAnnotatedSet2.class,
+ //AnnotatedSet2Ext.class,
+
+ OverrideAnnotatedGet.class.getSuperclass(),
+ OverrideAnnotatedIs.class.getSuperclass(),
+ OverrideAnnotatedSet.class.getSuperclass(),
+
+ // TODO: uncomment/update after 8132565 fix
+ //OverrideAbstractGet.class,
+ //OverrideAbstractGet2.class,
+ //AbstractGetExt.class,
+ //OverrideAbstractIs.class,
+ //OverrideAbstractIs2.class,
+ //AbstractIsExt.class
+ //OverrideAbstractSet.class,
+ //OverrideAbstractSet2.class,
+ //AbstractSetExt.class,
+
+ AbstractGet2Ext.class.getSuperclass(),
+ IGetImpl.class,
+ IGetImpl2.class,
+ IGetImpl3.class,
+ IIsImpl.class,
+ IIsImpl2.class,
+ IIsImpl3.class,
+ ISetImpl.class,
+ ISetImpl2.class,
+ ISetImpl3.class,
+ ic1,
+ // ic2, // TODO: uncomment/update after 8155013 fix
+ OverrideProtectedGet.class,
+ HideStaticGet.class
+ };
+
+ boolean passed = true;
+
+ for (Class> c: cases) {
+
+ java.lang.reflect.Field f = c.getDeclaredField("TESTCASE");
+ f.setAccessible(true);
+ String descr = f.get(c).toString();
+
+ System.out.println("\n" + c.getSimpleName() + " (" + descr + "):");
+ BeanInfo i;
+ try {
+ i = Introspector.getBeanInfo(c,
+ (c.equals(ic1) || c.equals(ic2)) ? null : Object.class);
+ }
+ catch (IntrospectionException e) { throw new RuntimeException(e); }
+
+ boolean ok;
+
+ if (isDefault(c)) {
+ ok = checkDefault(i);
+ } else {
+ ok = checkInfo(i, ignoreVals(c));
+ }
+ System.out.println(ok ? "OK" : "NOK");
+ passed = passed && ok;
+ }
+
+ if (!passed) { throw new RuntimeException("test failed"); }
+ System.out.println("\ntest passed");
+ }
+}
From 8499a7a0b3f0c80504025ce37b58d1026b7a9b4d Mon Sep 17 00:00:00 2001
From: Alexander Scherbatiy
Date: Thu, 28 Apr 2016 23:48:37 +0400
Subject: [PATCH 005/120] 8152677: [macosx] All files filter can't be selected
in JFileChooser
Reviewed-by: serb
---
.../com/apple/laf/AquaFileChooserUI.java | 13 ++-
.../8152677/SelectAllFilesFilterTest.java | 108 ++++++++++++++++++
2 files changed, 118 insertions(+), 3 deletions(-)
create mode 100644 jdk/test/javax/swing/JFileChooser/8152677/SelectAllFilesFilterTest.java
diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java
index 91e1e4e8c39..eaade120e04 100644
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java
@@ -112,7 +112,7 @@ public class AquaFileChooserUI extends FileChooserUI {
private AncestorListener ancestorListener = null;
private DropTarget dragAndDropTarget = null;
- private final AcceptAllFileFilter acceptAllFileFilter = new AcceptAllFileFilter();
+ private static final AcceptAllFileFilter acceptAllFileFilter = new AcceptAllFileFilter();
private AquaFileSystemModel model;
@@ -997,7 +997,7 @@ public class AquaFileChooserUI extends FileChooserUI {
// *****************************************
// ***** default AcceptAll file filter *****
// *****************************************
- protected class AcceptAllFileFilter extends FileFilter {
+ private static class AcceptAllFileFilter extends FileFilter {
public AcceptAllFileFilter() {
}
@@ -1305,6 +1305,8 @@ public class AquaFileChooserUI extends FileChooserUI {
protected class FilterComboBoxModel extends AbstractListModel implements ComboBoxModel,
PropertyChangeListener {
protected FileFilter[] filters;
+ Object oldFileFilter = getFileChooser().getFileFilter();
+
protected FilterComboBoxModel() {
super();
filters = getFileChooser().getChoosableFileFilters();
@@ -1321,12 +1323,17 @@ public class AquaFileChooserUI extends FileChooserUI {
}
public void setSelectedItem(Object filter) {
- if (filter != null && !containsFileFilter(filter)) {
+ if (filter != null && !isSelectedFileFilterInModel(filter)) {
+ oldFileFilter = filter;
getFileChooser().setFileFilter((FileFilter) filter);
fireContentsChanged(this, -1, -1);
}
}
+ private boolean isSelectedFileFilterInModel(Object filter) {
+ return Objects.equals(filter, oldFileFilter);
+ }
+
public Object getSelectedItem() {
// Ensure that the current filter is in the list.
// NOTE: we shouldnt' have to do this, since JFileChooser adds
diff --git a/jdk/test/javax/swing/JFileChooser/8152677/SelectAllFilesFilterTest.java b/jdk/test/javax/swing/JFileChooser/8152677/SelectAllFilesFilterTest.java
new file mode 100644
index 00000000000..bc17b04a306
--- /dev/null
+++ b/jdk/test/javax/swing/JFileChooser/8152677/SelectAllFilesFilterTest.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Robot;
+import javax.swing.JComboBox;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.SwingUtilities;
+import javax.swing.filechooser.FileFilter;
+import javax.swing.filechooser.FileNameExtensionFilter;
+
+/*
+ * @test
+ * @bug 8152677
+ * @requires (os.family == "mac")
+ * @summary [macosx] All files filter can't be selected in JFileChooser
+ * @run main SelectAllFilesFilterTest
+ */
+
+public class SelectAllFilesFilterTest {
+
+ private static final String LABEL_TEXT = "File Format:";
+ private static volatile JFileChooser fileChooser;
+ private static JComboBox comboBox;
+
+ public static void main(String[] args) throws Exception {
+
+ SwingUtilities.invokeLater(SelectAllFilesFilterTest::createAndShowGUI);
+
+ while (fileChooser == null) {
+ Thread.sleep(100);
+ }
+
+ Robot robot = new Robot();
+ robot.waitForIdle();
+
+ SwingUtilities.invokeAndWait(() -> {
+ comboBox = findComboBox(fileChooser);
+ comboBox.setSelectedIndex(0);
+ });
+ robot.waitForIdle();
+
+ SwingUtilities.invokeAndWait(() -> {
+ int selectedIndex = comboBox.getSelectedIndex();
+ fileChooser.setVisible(false);
+
+ if (selectedIndex != 0) {
+ throw new RuntimeException("Select All file filter is not selected!");
+ }
+ });
+ }
+
+ private static void createAndShowGUI() {
+ fileChooser = new JFileChooser();
+ fileChooser.setAcceptAllFileFilterUsed(true);
+ fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
+
+ FileFilter txtFilter = new FileNameExtensionFilter("Text files", "txt");
+ fileChooser.addChoosableFileFilter(txtFilter);
+ fileChooser.setFileFilter(txtFilter);
+ fileChooser.showOpenDialog(null);
+ }
+
+ private static JComboBox findComboBox(Component comp) {
+
+ if (comp instanceof JLabel) {
+ JLabel label = (JLabel) comp;
+ if (LABEL_TEXT.equals(label.getText())) {
+ return (JComboBox) label.getLabelFor();
+ }
+ }
+
+ if (comp instanceof Container) {
+ Container cont = (Container) comp;
+ for (int i = 0; i < cont.getComponentCount(); i++) {
+
+ JComboBox result = findComboBox(cont.getComponent(i));
+ if (result != null) {
+ return result;
+ }
+ }
+ }
+
+ return null;
+ }
+}
From a94f4aafd20dafa1ac27e3e0e7a5a1f18e2c750b Mon Sep 17 00:00:00 2001
From: Sergey Bylokhov
Date: Fri, 29 Apr 2016 15:44:04 +0300
Subject: [PATCH 006/120] 8143346: Broken link in java.beans.XMLEncoder
Reviewed-by: prr
---
jdk/src/demo/share/jvmti/index.html | 2 +-
.../libawt_lwawt/awt/JavaComponentAccessibility.m | 4 ++--
.../share/classes/java/awt/Toolkit.java | 2 +-
.../share/classes/java/beans/XMLDecoder.java | 7 ++++---
.../share/classes/java/beans/XMLEncoder.java | 7 ++++---
.../share/classes/javax/swing/JRootPane.java | 2 +-
.../classes/javax/swing/colorchooser/package.html | 8 ++++----
.../share/classes/javax/swing/event/package.html | 8 ++++----
.../classes/javax/swing/filechooser/package.html | 8 ++++----
.../share/classes/javax/swing/package.html | 14 +++++++-------
.../classes/javax/swing/plaf/basic/package.html | 6 +++---
.../classes/javax/swing/plaf/metal/package.html | 6 +++---
.../swing/plaf/multi/doc-files/multi_tsc.html | 6 +++---
.../classes/javax/swing/plaf/multi/package.html | 6 +++---
.../classes/javax/swing/plaf/nimbus/package.html | 4 ++--
.../share/classes/javax/swing/plaf/package.html | 6 +++---
.../plaf/synth/doc-files/synthFileFormat.html | 2 +-
.../share/classes/javax/swing/table/package.html | 8 ++++----
.../share/classes/javax/swing/text/Document.java | 2 +-
.../classes/javax/swing/text/html/package.html | 6 +++---
.../javax/swing/text/html/parser/package.html | 6 +++---
.../share/classes/javax/swing/text/package.html | 8 ++++----
.../classes/javax/swing/text/rtf/package.html | 6 +++---
.../share/classes/javax/swing/tree/package.html | 8 ++++----
.../share/classes/javax/swing/undo/package.html | 8 ++++----
25 files changed, 76 insertions(+), 74 deletions(-)
diff --git a/jdk/src/demo/share/jvmti/index.html b/jdk/src/demo/share/jvmti/index.html
index 25440a104d9..5791b8b046f 100644
--- a/jdk/src/demo/share/jvmti/index.html
+++ b/jdk/src/demo/share/jvmti/index.html
@@ -415,7 +415,7 @@ Additional information can also be found by doing a search on "jvmti" at
Various technical articles are also available through this website.
And don't forget the
Java Tutorials at
-http://java.sun.com/docs/books/tutorial
+http://docs.oracle.com/javase/tutorial
for getting a quick start on all the various interfaces.
Comments and Feedback
diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m
index 1b3ec43a9fe..e7b229f00e1 100644
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m
@@ -25,7 +25,7 @@
// External Java Accessibility links:
//
-//
+//
//
// (Sun's mailing list for Java accessibility)
@@ -973,7 +973,7 @@ static NSObject *sAttributeNamesLOCK = nil;
// Element's value (id)
// note that the appKit meaning of "accessibilityValue" is different from the java
// meaning of "accessibleValue", which is specific to numerical values
-// (http://java.sun.com/j2se/1.3/docs/api/javax/accessibility/AccessibleValue.html#setCurrentAccessibleValue(java.lang.Number))
+// (https://docs.oracle.com/javase/8/docs/api/javax/accessibility/AccessibleValue.html#setCurrentAccessibleValue-java.lang.Number-)
- (id)accessibilityValueAttribute
{
static JNF_STATIC_MEMBER_CACHE(jm_getCurrentAccessibleValue, sjc_CAccessibility, "getCurrentAccessibleValue", "(Ljavax/accessibility/AccessibleValue;Ljava/awt/Component;)Ljava/lang/Number;");
diff --git a/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java b/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java
index 9e7646fd320..bed5149c08a 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java
@@ -89,7 +89,7 @@ import javax.accessibility.AccessibilityProvider;
*
For more information, see
* Timing
* Focus Transfers, a section in
- * The Swing
+ * The Swing
* Tutorial.
*
* Making a top-level container visible.
diff --git a/jdk/src/java.desktop/share/classes/java/beans/XMLDecoder.java b/jdk/src/java.desktop/share/classes/java/beans/XMLDecoder.java
index d86ecfaf6bd..daae045316b 100644
--- a/jdk/src/java.desktop/share/classes/java/beans/XMLDecoder.java
+++ b/jdk/src/java.desktop/share/classes/java/beans/XMLDecoder.java
@@ -53,8 +53,8 @@ import org.xml.sax.helpers.DefaultHandler;
*
*
* For more information you might also want to check out
- * Long Term Persistence of JavaBeans Components: XML Schema,
+ *
+ * Long Term Persistence of JavaBeans Components: XML Schema,
* an article in The Swing Connection.
* @see XMLEncoder
* @see java.io.ObjectInputStream
@@ -284,7 +284,8 @@ public class XMLDecoder implements AutoCloseable {
* The {@code null} value may cause illegal parsing in such case.
* The same problem may occur, if the {@code owner} class
* does not contain expected method to call. See details here.
+ * href="http://www.oracle.com/technetwork/java/persistence3-139471.html">
+ * here.
*
* @param owner the owner of the default handler
* that can be used as a value of <java> element
diff --git a/jdk/src/java.desktop/share/classes/java/beans/XMLEncoder.java b/jdk/src/java.desktop/share/classes/java/beans/XMLEncoder.java
index ac4ab411ce4..7deaea30622 100644
--- a/jdk/src/java.desktop/share/classes/java/beans/XMLEncoder.java
+++ b/jdk/src/java.desktop/share/classes/java/beans/XMLEncoder.java
@@ -193,8 +193,8 @@ import java.nio.charset.UnsupportedCharsetException;
*
*
* For more information you might also want to check out
- * Using XMLEncoder,
+ *
+ * Using XMLEncoder,
* an article in The Swing Connection.
* @see XMLDecoder
* @see java.io.ObjectOutputStream
@@ -438,7 +438,8 @@ public class XMLEncoder extends Encoder implements AutoCloseable {
*
* For more information about using resource bundles with the
* XMLEncoder, see
- * http://java.sun.com/products/jfc/tsc/articles/persistence4/#i18n
+ *
+ * Creating Internationalized Applications,
*
* @param oldExp The expression that will be written
* to the stream.
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JRootPane.java b/jdk/src/java.desktop/share/classes/javax/swing/JRootPane.java
index 4061f2e2471..80dfb2954b4 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/JRootPane.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JRootPane.java
@@ -194,7 +194,7 @@ import sun.security.action.GetBooleanAction;
* @see JComponent
* @see BoxLayout
*
- * @see
+ * @see
* Mixing Heavy and Light Components
*
* @author David Kloba
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/colorchooser/package.html b/jdk/src/java.desktop/share/classes/javax/swing/colorchooser/package.html
index cb8030258c3..43ff5ee8739 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/colorchooser/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/colorchooser/package.html
@@ -37,10 +37,10 @@ component.
Most of the Swing API is not thread safe.
For details, see
Threads and Swing,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing,
a section in
-The Java Tutorial.
@@ -49,7 +49,7 @@ target="_top">The Java Tutorial.
This document forms the complete API specification. For overviews, tutorials,
examples, guides, and tool documentation, please see:
- - How to Use Color Choosers,
+
- How to Use Color Choosers,
a section in The Java Tutorial
- not thread safe.
For details, see
Threads and Swing,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing,
a section in
-The Java Tutorial.
Related Documentation
For overviews, tutorials, examples, guides, and tool documentation, please see:
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/filechooser/package.html b/jdk/src/java.desktop/share/classes/javax/swing/filechooser/package.html
index d850fc5b19e..fa06236262c 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/filechooser/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/filechooser/package.html
@@ -37,10 +37,10 @@ Contains classes and interfaces used by the JFileChooser component.
Most of the Swing API is not thread safe.
For details, see
Threads and Swing,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing,
a section in
-The Java Tutorial.
@@ -49,7 +49,7 @@ target="_top">The Java Tutorial.
This document forms the complete API specification. For overviews, tutorials,
examples, guides, and tool documentation, please see:
- - How to Use File Choosers,
+
- How to Use File Choosers,
a section in The Java Tutorial
- Internationalization Documentation
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/package.html b/jdk/src/java.desktop/share/classes/javax/swing/package.html
index 8050000ae91..934bb9025da 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/package.html
@@ -38,7 +38,7 @@ questions.
(all-Java language) components that,
to the maximum degree possible, work the same on all platforms.
For a programmer's guide to using these components, see
-Creating
a GUI with JFC/Swing, a trail in The Java Tutorial.
For other resources, see
@@ -123,9 +123,9 @@ input. Refer to {@link javax.swing.SwingWorker} for the preferred way to do such
processing when working with Swing.
More information on this topic can be found in the
-Swing tutorial,
+Swing tutorial,
in particular the section on
-Concurrency in Swing.
+Concurrency in Swing.
@@ -134,13 +134,13 @@ in particular the section on
For overviews, tutorials, examples, guides, and other documentation, please see:
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/package.html b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/package.html
index d02593c7455..347fc7cf9c8 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/package.html
@@ -55,10 +55,10 @@ encouraged.
Most of the Swing API is not thread safe.
For details, see
Threads and Swing,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing,
a section in
-The Java Tutorial.
@since 1.2
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/package.html b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/package.html
index 1c41e7f9577..db16ddda090 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/package.html
@@ -51,10 +51,10 @@ encouraged.
Most of the Swing API is not thread safe.
For details, see
Threads and Swing,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing,
a section in
-The Java Tutorial.
@since 1.2
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/doc-files/multi_tsc.html b/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/doc-files/multi_tsc.html
index 512b1a581ea..343db5479e2 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/doc-files/multi_tsc.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/doc-files/multi_tsc.html
@@ -18,7 +18,7 @@ Using the Multiplexing Look and Feel
This document is based on an article
originally published in
-The Swing
+The Swing
Connection.
@@ -65,12 +65,12 @@ This document has the following sections:
Before reading further, you should be familiar
with the concept of pluggable look and feels.
For basic information, see
-How to Set the Look and Feel,
+How to Set the Look and Feel,
a section in
The Java Tutorial.
For architectural details, you can read
Pluggable look-and-feel architecture, a section within
+href="http://www.oracle.com/technetwork/java/architecture-142923.html#pluggable">Pluggable look-and-feel architecture, a section within
a Swing Connection article.
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/package.html b/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/package.html
index 65d1aeafcfc..32b0d6b21af 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/package.html
@@ -53,10 +53,10 @@ the Multiplexing Look and Feel.
Most of the Swing API is not thread safe.
For details, see
Threads and Swing,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing,
a section in
-The Java Tutorial.
@since 1.2
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/package.html b/jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/package.html
index 14cac304214..f91d73781fd 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/package.html
@@ -88,10 +88,10 @@ encouraged.
Note:
Most of the Swing API is not thread safe.
For details, see
-Concurrency in Swing,
a section in
-The Java Tutorial.
@since 1.7
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/package.html b/jdk/src/java.desktop/share/classes/javax/swing/plaf/package.html
index c207c89b103..0fc8c538143 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/package.html
@@ -44,10 +44,10 @@ by the javax.swing.plaf.basic and
Most of the Swing API is not thread safe.
For details, see
Threads and Swing,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing,
a section in
-The Java Tutorial.
@since 1.2
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/doc-files/synthFileFormat.html b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/doc-files/synthFileFormat.html
index 202283049b5..0936b2951d3 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/doc-files/synthFileFormat.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/doc-files/synthFileFormat.html
@@ -950,7 +950,7 @@ div.example {
Beans persistance can be used to embed any Object. This is
typically used for embedding your own Painters, but can be used
for other arbritrary objects as well. Refer to http://java.sun.com/products/jfc/tsc/articles/persistence3/ for details on beans persistance.
+ href="http://www.oracle.com/technetwork/java/persistence3-139471.html">http://www.oracle.com/technetwork/java/persistence3-139471.html for details on beans persistance.
Backing Style
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/table/package.html b/jdk/src/java.desktop/share/classes/javax/swing/table/package.html
index f3fd20c8bb1..cf944823e91 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/table/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/table/package.html
@@ -43,10 +43,10 @@ with the tables are viewed and managed.
Most of the Swing API is not thread safe.
For details, see
Threads and Swing,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing,
a section in
-The Java Tutorial.
@@ -54,7 +54,7 @@ target="_top">The Java Tutorial.
For overviews, tutorials, examples, guides, and tool documentation, please see:
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/Document.java b/jdk/src/java.desktop/share/classes/javax/swing/text/Document.java
index 12c9a09bc5c..4cab9c4fe2d 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/Document.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/Document.java
@@ -166,7 +166,7 @@ import javax.swing.event.*;
*
*
* For more information on the Document class, see
- * The Swing Connection
+ * The Swing Connection
* and most particularly the article,
*
* The Element Interface.
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/html/package.html b/jdk/src/java.desktop/share/classes/javax/swing/text/html/package.html
index e0ab0354d53..c9c41b8cc22 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/package.html
@@ -37,10 +37,10 @@ for creating HTML text editors.
Most of the Swing API is not thread safe.
For details, see
Threads and Swing,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing,
a section in
-The Java Tutorial.
Package Specification
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/html/parser/package.html b/jdk/src/java.desktop/share/classes/javax/swing/text/html/parser/package.html
index d503bc741e7..05c53989142 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/parser/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/parser/package.html
@@ -40,10 +40,10 @@ the HTMLEditorKit.ParserCallback interface.
Most of the Swing API is not thread safe.
For details, see
Threads and Swing,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing,
a section in
-The Java Tutorial.
@see javax.swing.text.html.HTMLEditorKit.ParserCallback
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/package.html b/jdk/src/java.desktop/share/classes/javax/swing/text/package.html
index 4aa7804f544..1c38c251066 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/package.html
@@ -41,17 +41,17 @@ and key mapping.
Most of the Swing API is not thread safe.
For details, see
Threads and Swing,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing,
a section in
-The Java Tutorial.
Related Documentation
For overviews, tutorials, examples, guides, and tool documentation, please see:
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/rtf/package.html b/jdk/src/java.desktop/share/classes/javax/swing/text/rtf/package.html
index aa83e9fa502..9b62f229a93 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/rtf/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/rtf/package.html
@@ -38,10 +38,10 @@ text editors.
Most of the Swing API is not thread safe.
For details, see
Threads and Swing,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing,
a section in
-The Java Tutorial.
@since 1.2
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/tree/package.html b/jdk/src/java.desktop/share/classes/javax/swing/tree/package.html
index b6b58bbdabe..e820b3cb364 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/tree/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/tree/package.html
@@ -39,10 +39,10 @@ as how data associated with the tree nodes are viewed and managed.
Most of the Swing API is not thread safe.
For details, see
Threads and Swing,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing,
a section in
-The Java Tutorial.
@@ -50,7 +50,7 @@ target="_top">The Java Tutorial.
For overviews, tutorials, examples, guides, and tool documentation, please see:
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/undo/package.html b/jdk/src/java.desktop/share/classes/javax/swing/undo/package.html
index f4ae62d7b16..bf6d809fafb 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/undo/package.html
+++ b/jdk/src/java.desktop/share/classes/javax/swing/undo/package.html
@@ -37,17 +37,17 @@ in applications such as text editors.
Most of the Swing API is not thread safe.
For details, see
Threads and Swing,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing,
a section in
-The Java Tutorial.
Related Documentation
For overviews, tutorials, examples, guides, and tool documentation, please see:
From 4b793fa7ffa88cbba91575494aa0a573504e2f4a Mon Sep 17 00:00:00 2001
From: Phil Race
Date: Fri, 29 Apr 2016 09:16:06 -0700
Subject: [PATCH 007/120] 8039444: Swing applications not being displayed
properly
Reviewed-by: serb, vadim
---
.../native/libawt/java2d/d3d/D3DBadHardware.h | 129 +-----------------
1 file changed, 3 insertions(+), 126 deletions(-)
diff --git a/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DBadHardware.h b/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DBadHardware.h
index 91ee7b358a4..115626c857c 100644
--- a/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DBadHardware.h
+++ b/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DBadHardware.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -51,131 +51,8 @@ typedef struct ADAPTER_INFO {
static const ADAPTER_INFO badHardware[] = {
- // Intel HD
- // Clarkdale (Desktop) GMA HD Lines
- { 0x8086, 0x0042, NO_VERSION, OS_ALL },
- // Arrandale (Mobile) GMA HD Lines
- { 0x8086, 0x0046, NO_VERSION, OS_ALL },
-
- // Sandy Bridge HD Graphics 3000/2000
- { 0x8086, 0x0102, NO_VERSION, OS_ALL },
- { 0x8086, 0x0106, NO_VERSION, OS_ALL },
- { 0x8086, 0x0112, NO_VERSION, OS_ALL },
- { 0x8086, 0x0116, NO_VERSION, OS_ALL },
- { 0x8086, 0x0122, NO_VERSION, OS_ALL },
- { 0x8086, 0x0126, NO_VERSION, OS_ALL },
- { 0x8086, 0x010A, NO_VERSION, OS_ALL },
-
- // Ivy Bridge
- { 0x8086, 0x0162, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0162, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0166, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0166, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x016A, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x016A, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0152, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0152, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0156, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0156, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x015A, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x015A, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-
- // Haswell
- { 0x8086, 0x0402, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0402, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0406, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0406, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0412, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0412, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0416, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0416, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x041E, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x041E, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x040A, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x040A, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x041A, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x041A, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0A06, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0A06, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0A16, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0A16, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0A26, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0A26, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0A2E, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0A2E, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0A1E, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0A1E, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0A0E, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0A0E, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0D26, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0D26, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0D22, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0D22, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-
- // Reason: workaround for 6620073, 6612195
- // Intel 740
- { 0x8086, 0x7800, NO_VERSION, OS_ALL },
- { 0x8086, 0x1240, NO_VERSION, OS_ALL },
- { 0x8086, 0x7121, NO_VERSION, OS_ALL },
- { 0x8086, 0x7123, NO_VERSION, OS_ALL },
- { 0x8086, 0x7125, NO_VERSION, OS_ALL },
- { 0x8086, 0x1132, NO_VERSION, OS_ALL },
- // IEG
- { 0x8086, 0x2562, NO_VERSION, OS_ALL },
- { 0x8086, 0x3577, NO_VERSION, OS_ALL },
- { 0x8086, 0x2572, NO_VERSION, OS_ALL },
- { 0x8086, 0x3582, NO_VERSION, OS_ALL },
- { 0x8086, 0x358E, NO_VERSION, OS_ALL },
- // GMA
- { 0x8086, 0x2582, NO_VERSION, OS_ALL },
- { 0x8086, 0x2782, NO_VERSION, OS_ALL },
- { 0x8086, 0x2592, NO_VERSION, OS_ALL },
- { 0x8086, 0x2792, NO_VERSION, OS_ALL },
- { 0x8086, 0x2772, NO_VERSION, OS_ALL },
- { 0x8086, 0x2776, NO_VERSION, OS_ALL },
- { 0x8086, 0x27A2, NO_VERSION, OS_ALL },
- { 0x8086, 0x27A6, NO_VERSION, OS_ALL },
- { 0x8086, 0x27AE, NO_VERSION, OS_ALL },
- { 0x8086, 0x29D2, NO_VERSION, OS_ALL },
- { 0x8086, 0x29D3, NO_VERSION, OS_ALL },
- { 0x8086, 0x29B2, NO_VERSION, OS_ALL },
- { 0x8086, 0x29B3, NO_VERSION, OS_ALL },
- { 0x8086, 0x29C2, NO_VERSION, OS_ALL },
- { 0x8086, 0x29C3, NO_VERSION, OS_ALL },
- { 0x8086, 0xA001, NO_VERSION, OS_ALL },
- { 0x8086, 0xA002, NO_VERSION, OS_ALL },
- { 0x8086, 0xA011, NO_VERSION, OS_ALL },
- { 0x8086, 0xA012, NO_VERSION, OS_ALL },
- // GMA
- { 0x8086, 0x2972, NO_VERSION, OS_ALL },
- { 0x8086, 0x2973, NO_VERSION, OS_ALL },
- { 0x8086, 0x2992, NO_VERSION, OS_ALL },
- { 0x8086, 0x2993, NO_VERSION, OS_ALL },
- { 0x8086, 0x29A2, NO_VERSION, OS_ALL },
- { 0x8086, 0x29A3, NO_VERSION, OS_ALL },
- { 0x8086, 0x2982, NO_VERSION, OS_ALL },
- { 0x8086, 0x2983, NO_VERSION, OS_ALL },
- { 0x8086, 0x2A02, NO_VERSION, OS_ALL },
- { 0x8086, 0x2A03, NO_VERSION, OS_ALL },
- { 0x8086, 0x2A12, NO_VERSION, OS_ALL },
- { 0x8086, 0x2A13, NO_VERSION, OS_ALL },
-
- // Eaglelake (Desktop) GMA 4500 Lines
- { 0x8086, 0x2E42, NO_VERSION, OS_ALL },
- { 0x8086, 0x2E43, NO_VERSION, OS_ALL },
- { 0x8086, 0x2E92, NO_VERSION, OS_ALL },
- { 0x8086, 0x2E93, NO_VERSION, OS_ALL },
- { 0x8086, 0x2E12, NO_VERSION, OS_ALL },
- { 0x8086, 0x2E13, NO_VERSION, OS_ALL },
- // Eaglelake (Desktop) GMA X4500 Lines
- { 0x8086, 0x2E32, NO_VERSION, OS_ALL },
- { 0x8086, 0x2E33, NO_VERSION, OS_ALL },
- { 0x8086, 0x2E22, NO_VERSION, OS_ALL },
- // Eaglelake (Desktop) GMA X4500HD Lines
- { 0x8086, 0x2E23, NO_VERSION, OS_ALL },
- // Cantiga (Mobile) GMA 4500MHD Lines
- { 0x8086, 0x2A42, NO_VERSION, OS_ALL },
- { 0x8086, 0x2A43, NO_VERSION, OS_ALL },
+ // All Intel Chips.
+ { 0x8086, ALL_DEVICEIDS, NO_VERSION, OS_ALL },
// ATI Mobility Radeon X1600, X1400, X1450, X1300, X1350
// Reason: workaround for 6613066, 6687166
From bf6b990945a035ad0f5bc76987be75f2bbc6819b Mon Sep 17 00:00:00 2001
From: Alexander Scherbatiy
Date: Fri, 29 Apr 2016 21:59:47 +0400
Subject: [PATCH 008/120] 8017112: JTabbedPane components have inconsistent
accessibility tree
Reviewed-by: ptbrunet, serb
---
.../share/classes/java/awt/Component.java | 27 +++++---
.../8017112/AccessibleIndexInParentTest.java | 68 +++++++++++++++++++
2 files changed, 84 insertions(+), 11 deletions(-)
create mode 100644 jdk/test/javax/accessibility/8017112/AccessibleIndexInParentTest.java
diff --git a/jdk/src/java.desktop/share/classes/java/awt/Component.java b/jdk/src/java.desktop/share/classes/java/awt/Component.java
index b2b51e08559..c2a021fd595 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/Component.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/Component.java
@@ -9739,19 +9739,24 @@ public abstract class Component implements ImageObserver, MenuContainer,
*/
int getAccessibleIndexInParent() {
synchronized (getTreeLock()) {
- int index = -1;
- Container parent = this.getParent();
- if (parent != null && parent instanceof Accessible) {
- Component ca[] = parent.getComponents();
- for (int i = 0; i < ca.length; i++) {
- if (ca[i] instanceof Accessible) {
- index++;
- }
- if (this.equals(ca[i])) {
- return index;
- }
+
+ AccessibleContext accContext = getAccessibleContext();
+ if (accContext == null) {
+ return -1;
+ }
+
+ Accessible parent = accContext.getAccessibleParent();
+ if (parent == null) {
+ return -1;
+ }
+
+ accContext = parent.getAccessibleContext();
+ for (int i = 0; i < accContext.getAccessibleChildrenCount(); i++) {
+ if (this.equals(accContext.getAccessibleChild(i))) {
+ return i;
}
}
+
return -1;
}
}
diff --git a/jdk/test/javax/accessibility/8017112/AccessibleIndexInParentTest.java b/jdk/test/javax/accessibility/8017112/AccessibleIndexInParentTest.java
new file mode 100644
index 00000000000..87f35b40da9
--- /dev/null
+++ b/jdk/test/javax/accessibility/8017112/AccessibleIndexInParentTest.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Component;
+import javax.swing.JLabel;
+import javax.swing.JTabbedPane;
+import javax.swing.SwingUtilities;
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleContext;
+/*
+ * @test
+ * @bug 8017112
+ * @summary JTabbedPane components have inconsistent accessibility tree
+ * @run main AccessibleIndexInParentTest
+ */
+
+public class AccessibleIndexInParentTest {
+
+ public static void main(String[] args) throws Exception {
+ SwingUtilities.invokeAndWait(AccessibleIndexInParentTest::test);
+ }
+
+ private static void test() {
+
+ int N = 5;
+ JTabbedPane tabbedPane = new JTabbedPane();
+
+ for (int i = 0; i < N; i++) {
+ tabbedPane.addTab("Title: " + i, new JLabel("Component: " + i));
+ }
+
+ for (int i = 0; i < tabbedPane.getTabCount(); i++) {
+ Component child = tabbedPane.getComponentAt(i);
+
+ AccessibleContext ac = child.getAccessibleContext();
+ if (ac == null) {
+ throw new RuntimeException("Accessible Context is null!");
+ }
+
+ int index = ac.getAccessibleIndexInParent();
+ Accessible parent = ac.getAccessibleParent();
+
+ if (parent.getAccessibleContext().getAccessibleChild(index) != child) {
+ throw new RuntimeException("Wrong getAccessibleIndexInParent!");
+ }
+ }
+ }
+}
\ No newline at end of file
From 6a55291a23f5116c16c27c7a7f152bcf8e45adb3 Mon Sep 17 00:00:00 2001
From: Brian Burkhalter
Date: Fri, 29 Apr 2016 11:14:56 -0700
Subject: [PATCH 009/120] 8151323: GeoTIFFTagSet#"ModelTiePointTag" name case
does not match GeoTIFF specification
Change occurrences of "ModelTiePoint" to "ModelTiepoint."
Reviewed-by: prr
---
.../classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java
index 28ee56abd3c..58adc761f29 100644
--- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java
@@ -87,9 +87,9 @@ public class GeoTIFFTagSet extends TIFFTagSet {
}
}
- static class ModelTiePoint extends TIFFTag {
- public ModelTiePoint() {
- super("ModelTiePointTag",
+ static class ModelTiepoint extends TIFFTag {
+ public ModelTiepoint() {
+ super("ModelTiepointTag",
TAG_MODEL_TIE_POINT,
1 << TIFFTag.TIFF_DOUBLE);
}
@@ -126,7 +126,7 @@ public class GeoTIFFTagSet extends TIFFTagSet {
tags.add(new GeoTIFFTagSet.ModelPixelScale());
tags.add(new GeoTIFFTagSet.ModelTransformation());
- tags.add(new GeoTIFFTagSet.ModelTiePoint());
+ tags.add(new GeoTIFFTagSet.ModelTiepoint());
tags.add(new GeoTIFFTagSet.GeoKeyDirectory());
tags.add(new GeoTIFFTagSet.GeoDoubleParams());
tags.add(new GeoTIFFTagSet.GeoAsciiParams());
From fed3d6ceac50ab9e33fcdf74ab4a8d6e26348200 Mon Sep 17 00:00:00 2001
From: Brian Burkhalter
Date: Fri, 29 Apr 2016 14:50:50 -0700
Subject: [PATCH 010/120] 8149810: TIFFField#getAsLong throws
ClassCastException when data is type TIFFTag.TIFF_DOUBLE or TIFFTag.FLOAT
Expand the getAsLong() specification and handle the TIFF_DOUBLE and TIFF_FLOAT cases.
Reviewed-by: prr
---
.../javax/imageio/plugins/tiff/TIFFField.java | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java
index 336f81550b7..168e6b17328 100644
--- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java
@@ -1089,6 +1089,15 @@ public class TIFFField implements Cloneable {
* {@code TIFF_SBYTE} data will be returned in the range
* [-128, 127].
*
+ * Data in {@code TIFF_FLOAT} and {@code TIFF_DOUBLE} are
+ * simply cast to {@code long} and may suffer from truncation.
+ *
+ *
Data in {@code TIFF_SRATIONAL} or
+ * {@code TIFF_RATIONAL} format are evaluated by dividing the
+ * numerator into the denominator using double-precision
+ * arithmetic and then casting to {@code long}. Loss of
+ * precision and truncation may occur.
+ *
*
Data in {@code TIFF_ASCII} format will be parsed as by
* the {@code Double.parseDouble} method, with the result
* cast to {@code long}.
@@ -1112,6 +1121,10 @@ public class TIFFField implements Cloneable {
case TIFFTag.TIFF_LONG:
case TIFFTag.TIFF_IFD_POINTER:
return ((long[])data)[index];
+ case TIFFTag.TIFF_FLOAT:
+ return (long)((float[])data)[index];
+ case TIFFTag.TIFF_DOUBLE:
+ return (long)((double[])data)[index];
case TIFFTag.TIFF_SRATIONAL:
int[] ivalue = getAsSRational(index);
return (long)((double)ivalue[0]/ivalue[1]);
From 5dda2fc113cd2a7c2c252f2726d200213f18bd8d Mon Sep 17 00:00:00 2001
From: Phil Race
Date: Fri, 29 Apr 2016 16:37:02 -0700
Subject: [PATCH 011/120] 8155772: gtk3_interface.c compilation error on Ubuntu
12.10
Reviewed-by: serb, kcr
---
.../java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c
index 6a188fb3598..060b082e53b 100644
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c
@@ -2547,14 +2547,14 @@ static jobject get_string_property(JNIEnv *env, GtkSettings* settings,
static jobject get_integer_property(JNIEnv *env, GtkSettings* settings,
const gchar* key) {
- gint intval = NULL;
+ gint intval = 0;
(*fp_g_object_get)(settings, key, &intval, NULL);
return create_Integer(env, intval);
}
static jobject get_boolean_property(JNIEnv *env, GtkSettings* settings,
const gchar* key) {
- gint intval = NULL;
+ gint intval = 0;
(*fp_g_object_get)(settings, key, &intval, NULL);
return create_Boolean(env, intval);
}
From 1f092412dccc3eeb353c0ef4ab360a5999f2e050 Mon Sep 17 00:00:00 2001
From: Sergey Bylokhov
Date: Mon, 2 May 2016 12:01:39 +0300
Subject: [PATCH 012/120] 8154493: AppletViewer should emit its deprecation
warning to standard error
Reviewed-by: smarks
---
jdk/src/java.desktop/share/classes/sun/applet/Main.java | 3 ++-
.../DeprecatedAppletViewer/DeprecatedAppletViewer.java | 6 +++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/jdk/src/java.desktop/share/classes/sun/applet/Main.java b/jdk/src/java.desktop/share/classes/sun/applet/Main.java
index 086b1113614..6c28c8f9d11 100644
--- a/jdk/src/java.desktop/share/classes/sun/applet/Main.java
+++ b/jdk/src/java.desktop/share/classes/sun/applet/Main.java
@@ -104,7 +104,8 @@ public class Main {
private int run(String [] args) {
// DECODE ARGS
try {
- System.out.println(lookup("deprecated"));
+ System.err.println(lookup("deprecated"));
+ System.err.flush();
if (args.length == 0) {
usage();
return 0;
diff --git a/jdk/test/sun/applet/DeprecatedAppletViewer/DeprecatedAppletViewer.java b/jdk/test/sun/applet/DeprecatedAppletViewer/DeprecatedAppletViewer.java
index f3b43f83eee..3c491011794 100644
--- a/jdk/test/sun/applet/DeprecatedAppletViewer/DeprecatedAppletViewer.java
+++ b/jdk/test/sun/applet/DeprecatedAppletViewer/DeprecatedAppletViewer.java
@@ -35,14 +35,14 @@ public final class DeprecatedAppletViewer {
private static final String TEXT = "AppletViewer is deprecated.";
public static void main(final String[] args) {
- final PrintStream old = System.out;
+ final PrintStream old = System.err;
final ByteArrayOutputStream baos = new ByteArrayOutputStream(1000);
final PrintStream ps = new PrintStream(baos);
try {
- System.setOut(ps);
+ System.setErr(ps);
sun.applet.Main.main(new String[]{});
} finally {
- System.setOut(old);
+ System.setErr(old);
}
final String text = new String(baos.toByteArray());
From 36865021a112e983a33d495d4a1ab0d4490ae2b0 Mon Sep 17 00:00:00 2001
From: Sergey Bylokhov
Date: Mon, 2 May 2016 12:08:59 +0300
Subject: [PATCH 013/120] 8027324: The spec for Toolkit.setDynamicLayout() and
Toolkit.isDynamicLayoutActive() needs to be clarified
Reviewed-by: alexsch, prr
---
.../share/classes/java/awt/Toolkit.java | 52 ++++++++++---------
.../awt/Toolkit/DynamicLayout/bug7172833.java | 22 +++++++-
2 files changed, 48 insertions(+), 26 deletions(-)
diff --git a/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java b/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java
index bed5149c08a..b45dd39a717 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -207,30 +207,34 @@ public abstract class Toolkit {
}
/**
- * Returns whether dynamic layout of Containers on resize is
- * currently active (both set in program
- *( {@code isDynamicLayoutSet()} )
- *, and supported
- * by the underlying operating system and/or window manager).
- * If dynamic layout is currently inactive then Containers
- * re-layout their components when resizing is completed. As a result
- * the {@code Component.validate()} method will be invoked only
- * once per resize.
- * If dynamic layout is currently active then Containers
- * re-layout their components on every native resize event and
- * the {@code validate()} method will be invoked each time.
- * The OS/WM support can be queried using
- * the getDesktopProperty("awt.dynamicLayoutSupported") method.
+ * Returns whether dynamic layout of Containers on resize is currently
+ * enabled on the underlying operating system and/or window manager). If the
+ * platform supports it, {@code setDynamicLayout(boolean)} may be used to
+ * programmatically enable or disable platform dynamic layout. Regardless of
+ * whether that toggling is supported, or whether {@code true} or {@code
+ * false} is specified as an argument, or has never been called at all, this
+ * method will return the active current platform behavior and which will be
+ * followed by the JDK in determining layout policy during resizing.
+ *
+ * If dynamic layout is currently inactive then Containers re-layout their
+ * components when resizing is completed. As a result the
+ * {@code Component.validate()} method will be invoked only once per resize.
+ * If dynamic layout is currently active then Containers re-layout their
+ * components on every native resize event and the {@code validate()} method
+ * will be invoked each time. The OS/WM support can be queried using the
+ * getDesktopProperty("awt.dynamicLayoutSupported") method. This property
+ * will reflect the platform capability but is not sufficient to tell if it
+ * is presently enabled.
*
- * @return true if dynamic layout of Containers on resize is
- * currently active, false otherwise.
- * @exception HeadlessException if the GraphicsEnvironment.isHeadless()
- * method returns true
- * @see #setDynamicLayout(boolean dynamic)
- * @see #isDynamicLayoutSet()
- * @see #getDesktopProperty(String propertyName)
- * @see java.awt.GraphicsEnvironment#isHeadless
- * @since 1.4
+ * @return true if dynamic layout of Containers on resize is currently
+ * active, false otherwise.
+ * @throws HeadlessException if the GraphicsEnvironment.isHeadless() method
+ * returns true
+ * @see #setDynamicLayout(boolean dynamic)
+ * @see #isDynamicLayoutSet()
+ * @see #getDesktopProperty(String propertyName)
+ * @see java.awt.GraphicsEnvironment#isHeadless
+ * @since 1.4
*/
public boolean isDynamicLayoutActive()
throws HeadlessException {
diff --git a/jdk/test/java/awt/Toolkit/DynamicLayout/bug7172833.java b/jdk/test/java/awt/Toolkit/DynamicLayout/bug7172833.java
index 7c61804892b..2c4f04147b8 100644
--- a/jdk/test/java/awt/Toolkit/DynamicLayout/bug7172833.java
+++ b/jdk/test/java/awt/Toolkit/DynamicLayout/bug7172833.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -45,16 +45,34 @@ public final class bug7172833 {
public static void main(final String[] args) throws Exception {
final StubbedToolkit t = new StubbedToolkit();
-
+ final Boolean dynamicLayoutSupported
+ = (Boolean) t.getDesktopProperty("awt.dynamicLayoutSupported");
t.setDynamicLayout(true);
if(!t.isDynamicLayoutSet()){
throw new RuntimeException("'true' expected but 'false' returned");
}
+ if (dynamicLayoutSupported) {
+ if (!t.isDynamicLayoutActive()) {
+ throw new RuntimeException("is inactive but set+supported");
+ }
+ } else {
+ if (t.isDynamicLayoutActive()) {
+ throw new RuntimeException("is active but unsupported");
+ }
+ }
t.setDynamicLayout(false);
if(t.isDynamicLayoutSet()){
throw new RuntimeException("'false' expected but 'true' returned");
}
+ if (dynamicLayoutSupported) {
+ // Layout is supported and was set to false, cannot verifym because
+ // the native system is free to ignore our request.
+ } else {
+ if (t.isDynamicLayoutActive()) {
+ throw new RuntimeException("is active but unset+unsupported");
+ }
+ }
}
static final class StubbedToolkit extends Toolkit {
From 905d21fe7681109c9a5c959407be09aa4ae7fda6 Mon Sep 17 00:00:00 2001
From: Athijegannathan Sundararajan
Date: Mon, 16 May 2016 14:47:27 +0530
Subject: [PATCH 014/120] 8156914: jlink API minor cleanups
Reviewed-by: mchung
---
.../share/classes/jdk/tools/jlink/Jlink.java | 30 +-
.../jlink/builder/DefaultImageBuilder.java | 108 ++--
.../jdk/tools/jlink/builder/ImageBuilder.java | 6 +-
.../jlink/internal/ImageFileCreator.java | 55 +-
.../internal/ImagePluginConfiguration.java | 43 +-
.../jlink/internal/ImagePluginStack.java | 187 ++++---
.../tools/jlink/internal/ModuleEntryImpl.java | 164 ++++++
.../tools/jlink/internal/ModulePoolImpl.java | 421 ++++++++++++++
.../jlink/internal/PluginContextImpl.java | 37 --
.../jdk/tools/jlink/internal/PoolImpl.java | 167 ------
.../jlink/internal/ResourcePrevisitor.java | 4 +-
.../jdk/tools/jlink/internal/TaskHelper.java | 9 +-
.../jdk/tools/jlink/internal/Utils.java | 48 +-
.../packager/AppRuntimeImageBuilder.java | 2 +-
.../plugins/DefaultCompressPlugin.java | 21 +-
.../internal/plugins/ExcludeFilesPlugin.java | 16 +-
.../jlink/internal/plugins/ExcludePlugin.java | 15 +-
.../internal/plugins/ExcludeVMPlugin.java | 31 +-
.../internal/plugins/FileCopierPlugin.java | 34 +-
.../plugins/GenerateJLIClassesPlugin.java | 23 +-
.../plugins/IncludeLocalesPlugin.java | 29 +-
.../internal/plugins/OptimizationPlugin.java | 7 +-
.../plugins/OrderResourcesPlugin.java | 29 +-
.../internal/plugins/ReleaseInfoPlugin.java | 103 ++--
.../internal/plugins/StringSharingPlugin.java | 36 +-
.../internal/plugins/StripDebugPlugin.java | 22 +-
.../plugins/StripNativeCommandsPlugin.java | 16 +-
.../plugins/SystemModuleDescriptorPlugin.java | 39 +-
.../jlink/internal/plugins/ZipPlugin.java | 25 +-
.../jlink/internal/plugins/asm/AsmPlugin.java | 16 +-
.../jlink/internal/plugins/asm/AsmPool.java | 25 +-
.../internal/plugins/asm/AsmPoolImpl.java | 93 ++-
.../jlink/internal/plugins/asm/AsmPools.java | 72 +--
.../tools/jlink/plugin/ExecutableImage.java | 39 +-
.../jdk/tools/jlink/plugin/LinkModule.java | 87 +++
.../jdk/tools/jlink/plugin/ModuleEntry.java | 155 +++++
.../jdk/tools/jlink/plugin/ModulePool.java | 136 +++++
.../jdk/tools/jlink/plugin/Plugin.java | 40 +-
.../jdk/tools/jlink/plugin/PluginContext.java | 37 --
.../classes/jdk/tools/jlink/plugin/Pool.java | 528 ------------------
.../tools/jlink/plugin/TransformerPlugin.java | 2 +-
.../jdk.jlink/share/classes/module-info.java | 4 +-
jdk/test/tools/jlink/DefaultProviderTest.java | 18 +-
.../tools/jlink/ImageFileCreatorTest.java | 5 +-
jdk/test/tools/jlink/ImageFilePoolTest.java | 59 +-
jdk/test/tools/jlink/IntegrationTest.java | 20 +-
jdk/test/tools/jlink/JLinkOptimTest.java | 30 +-
jdk/test/tools/jlink/JLinkOptionsTest.java | 4 +-
.../tools/jlink/JLinkPostProcessingTest.java | 6 +-
jdk/test/tools/jlink/ResourcePoolTest.java | 122 ++--
jdk/test/tools/jlink/SecurityTest.java | 1 +
.../asmplugin/AddForgetResourcesTest.java | 84 +--
.../jlink/asmplugin/AsmPluginTestBase.java | 36 +-
jdk/test/tools/jlink/asmplugin/BasicTest.java | 16 +-
.../jlink/asmplugin/IdentityPluginTest.java | 25 +-
.../tools/jlink/asmplugin/NegativeTest.java | 8 +-
.../jlink/asmplugin/PackageMappingTest.java | 12 +-
.../tools/jlink/asmplugin/SortingTest.java | 42 +-
.../tools/jlink/asmplugin/VisitorTest.java | 22 +-
.../customplugin/plugin/CustomPlugin.java | 19 +-
.../customplugin/plugin/HelloPlugin.java | 16 +-
.../jlink/plugins/CompressorPluginTest.java | 82 +--
.../jlink/plugins/ExcludeFilesPluginTest.java | 19 +-
.../jlink/plugins/ExcludePluginTest.java | 16 +-
.../jlink/plugins/ExcludeVMPluginTest.java | 37 +-
.../jlink/plugins/FileCopierPluginTest.java | 21 +-
.../tools/jlink/plugins/LastSorterTest.java | 53 +-
.../plugins/OrderResourcesPluginTest.java | 79 +--
.../tools/jlink/plugins/PluginOrderTest.java | 58 +-
.../jlink/plugins/PluginsNegativeTest.java | 22 +-
.../tools/jlink/plugins/PrevisitorTest.java | 49 +-
.../plugins/StringSharingPluginTest.java | 26 +-
.../jlink/plugins/StripDebugPluginTest.java | 20 +-
73 files changed, 2077 insertions(+), 1911 deletions(-)
create mode 100644 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryImpl.java
create mode 100644 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java
delete mode 100644 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PluginContextImpl.java
delete mode 100644 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PoolImpl.java
create mode 100644 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/LinkModule.java
create mode 100644 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModuleEntry.java
create mode 100644 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModulePool.java
delete mode 100644 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java
delete mode 100644 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Pool.java
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/Jlink.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/Jlink.java
index 92d7eb64fcf..e899d378963 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/Jlink.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/Jlink.java
@@ -34,11 +34,9 @@ import java.util.Objects;
import java.util.Set;
import jdk.tools.jlink.internal.JlinkTask;
import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.PluginContext;
import jdk.tools.jlink.plugin.PluginException;
import jdk.tools.jlink.plugin.ExecutableImage;
import jdk.tools.jlink.builder.ImageBuilder;
-import jdk.tools.jlink.internal.PluginContextImpl;
import jdk.tools.jlink.internal.PluginRepository;
/**
@@ -71,7 +69,6 @@ public final class Jlink {
private final List plugins;
private final ImageBuilder imageBuilder;
private final String lastSorterPluginName;
- private final PluginContext pluginContext;
/**
* Empty plugins configuration.
@@ -86,7 +83,7 @@ public final class Jlink {
* @param plugins List of plugins.
*/
public PluginsConfiguration(List plugins) {
- this(plugins, null, null, null);
+ this(plugins, null, null);
}
/**
@@ -101,28 +98,10 @@ public final class Jlink {
*/
public PluginsConfiguration(List plugins,
ImageBuilder imageBuilder, String lastSorterPluginName) {
- this(plugins, imageBuilder, lastSorterPluginName, null);
- }
-
- /**
- * Plugins configuration with a last sorter and an ImageBuilder. No
- * sorting can occur after the last sorter plugin. The ImageBuilder is
- * in charge to layout the image content on disk.
- *
- * @param plugins List of transformer plugins.
- * @param imageBuilder Image builder.
- * @param lastSorterPluginName Name of last sorter plugin, no sorting
- * @param ctx the plugin context
- * can occur after it.
- */
- public PluginsConfiguration(List plugins,
- ImageBuilder imageBuilder, String lastSorterPluginName,
- PluginContext ctx) {
this.plugins = plugins == null ? Collections.emptyList()
: plugins;
this.imageBuilder = imageBuilder;
this.lastSorterPluginName = lastSorterPluginName;
- this.pluginContext = ctx != null? ctx : new PluginContextImpl();
}
/**
@@ -146,13 +125,6 @@ public final class Jlink {
return lastSorterPluginName;
}
- /**
- * @return the pluginContext
- */
- public PluginContext getPluginContext() {
- return pluginContext;
- }
-
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java
index a3943145c06..2c0620a99db 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java
@@ -1,3 +1,4 @@
+
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -24,8 +25,6 @@
*/
package jdk.tools.jlink.builder;
-import jdk.tools.jlink.plugin.ExecutableImage;
-import jdk.tools.jlink.plugin.PluginException;
import java.io.BufferedOutputStream;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
@@ -47,8 +46,10 @@ import java.nio.file.StandardOpenOption;
import java.nio.file.attribute.PosixFileAttributeView;
import java.nio.file.attribute.PosixFilePermission;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Properties;
@@ -56,23 +57,40 @@ import java.util.Set;
import jdk.tools.jlink.internal.BasicImageWriter;
import jdk.tools.jlink.internal.plugins.FileCopierPlugin;
import jdk.tools.jlink.internal.plugins.FileCopierPlugin.SymImageFile;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.Module;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ExecutableImage;
+import jdk.tools.jlink.plugin.ModulePool;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.PluginException;
/**
*
* Default Image Builder. This builder creates the default runtime image layout.
*/
-public class DefaultImageBuilder implements ImageBuilder {
+public final class DefaultImageBuilder implements ImageBuilder {
/**
* The default java executable Image.
*/
- static class DefaultExecutableImage extends ExecutableImage {
+ static final class DefaultExecutableImage implements ExecutableImage {
+
+ private final Path home;
+ private final List args;
+ private final Set modules;
public DefaultExecutableImage(Path home, Set modules) {
- super(home, modules, createArgs(home));
+ this(home, modules, createArgs(home));
+ }
+
+ private DefaultExecutableImage(Path home, Set modules,
+ List args) {
+ Objects.requireNonNull(home);
+ Objects.requireNonNull(args);
+ if (!Files.exists(home)) {
+ throw new IllegalArgumentException("Invalid image home");
+ }
+ this.home = home;
+ this.modules = Collections.unmodifiableSet(modules);
+ this.args = Collections.unmodifiableList(args);
}
private static List createArgs(Path home) {
@@ -83,6 +101,21 @@ public class DefaultImageBuilder implements ImageBuilder {
return javaArgs;
}
+ @Override
+ public Path getHome() {
+ return home;
+ }
+
+ @Override
+ public Set getModules() {
+ return modules;
+ }
+
+ @Override
+ public List getExecutionArgs() {
+ return args;
+ }
+
@Override
public void storeLaunchArgs(List args) {
try {
@@ -111,17 +144,19 @@ public class DefaultImageBuilder implements ImageBuilder {
Files.createDirectories(mdir);
}
- private void storeFiles(Set modules, Properties release) throws IOException {
+ private void storeFiles(Set modules, Map release) throws IOException {
if (release != null) {
- addModules(release, modules);
+ Properties props = new Properties();
+ props.putAll(release);
+ addModules(props, modules);
File r = new File(root.toFile(), "release");
try (FileOutputStream fo = new FileOutputStream(r)) {
- release.store(fo, null);
+ props.store(fo, null);
}
}
}
- private void addModules(Properties release, Set modules) throws IOException {
+ private void addModules(Properties props, Set modules) throws IOException {
StringBuilder builder = new StringBuilder();
int i = 0;
for (String m : modules) {
@@ -131,28 +166,32 @@ public class DefaultImageBuilder implements ImageBuilder {
}
i++;
}
- release.setProperty("MODULES", builder.toString());
+ props.setProperty("MODULES", builder.toString());
}
@Override
- public void storeFiles(Pool files, Properties release) {
+ public void storeFiles(ModulePool files) {
try {
- for (ModuleData f : files.getContent()) {
- if (!f.getType().equals(Pool.ModuleDataType.CLASS_OR_RESOURCE)) {
- accept(f);
+ files.entries().forEach(f -> {
+ if (!f.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) {
+ try {
+ accept(f);
+ } catch (IOException ioExp) {
+ throw new UncheckedIOException(ioExp);
+ }
}
- }
- for (Module m : files.getModules()) {
+ });
+ files.modules().forEach(m -> {
// Only add modules that contain packages
if (!m.getAllPackages().isEmpty()) {
// Skip the fake module used by FileCopierPlugin when copying files.
if (m.getName().equals(FileCopierPlugin.FAKE_MODULE)) {
- continue;
+ return;
}
modules.add(m.getName());
}
- }
- storeFiles(modules, release);
+ });
+ storeFiles(modules, files.getReleaseProperties());
if (Files.getFileStore(root).supportsFileAttributeView(PosixFileAttributeView.class)) {
// launchers in the bin directory need execute permission
@@ -168,8 +207,8 @@ public class DefaultImageBuilder implements ImageBuilder {
Path lib = root.resolve("lib");
if (Files.isDirectory(lib)) {
Files.find(lib, 2, (path, attrs) -> {
- return path.getFileName().toString().equals("jspawnhelper") ||
- path.getFileName().toString().equals("jexec");
+ return path.getFileName().toString().equals("jspawnhelper")
+ || path.getFileName().toString().equals("jexec");
}).forEach(this::setExecutable);
}
}
@@ -180,27 +219,23 @@ public class DefaultImageBuilder implements ImageBuilder {
}
}
- @Override
- public void storeFiles(Pool files) {
- storeFiles(files, new Properties());
- }
-
/**
* Generates launcher scripts.
+ *
* @param imageContent The image content.
* @param modules The set of modules that the runtime image contains.
* @throws IOException
*/
- protected void prepareApplicationFiles(Pool imageContent, Set modules) throws IOException {
+ protected void prepareApplicationFiles(ModulePool imageContent, Set modules) throws IOException {
// generate launch scripts for the modules with a main class
for (String module : modules) {
String path = "/" + module + "/module-info.class";
- ModuleData res = imageContent.get(path);
- if (res == null) {
+ Optional res = imageContent.findEntry(path);
+ if (!res.isPresent()) {
throw new IOException("module-info.class not found for " + module + " module");
}
Optional mainClass;
- ByteArrayInputStream stream = new ByteArrayInputStream(res.getBytes());
+ ByteArrayInputStream stream = new ByteArrayInputStream(res.get().getBytes());
mainClass = ModuleDescriptor.read(stream).mainClass();
if (mainClass.isPresent()) {
Path cmd = root.resolve("bin").resolve(module);
@@ -263,9 +298,9 @@ public class DefaultImageBuilder implements ImageBuilder {
}
}
- private void accept(ModuleData file) throws IOException {
+ private void accept(ModuleEntry file) throws IOException {
String fullPath = file.getPath();
- String module = "/" + file.getModule()+ "/";
+ String module = "/" + file.getModule() + "/";
String filename = fullPath.substring(module.length());
// Remove radical native|config|...
filename = filename.substring(filename.indexOf('/') + 1);
@@ -404,8 +439,7 @@ public class DefaultImageBuilder implements ImageBuilder {
public static ExecutableImage getExecutableImage(Path root) {
if (Files.exists(root.resolve("bin").resolve(getJavaProcessName()))) {
- return new DefaultImageBuilder.DefaultExecutableImage(root,
- retrieveModules(root));
+ return new DefaultExecutableImage(root, retrieveModules(root));
}
return null;
}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/ImageBuilder.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/ImageBuilder.java
index dc0bf71c535..10cea85d363 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/ImageBuilder.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/ImageBuilder.java
@@ -29,7 +29,7 @@ import java.util.Properties;
import jdk.tools.jlink.plugin.ExecutableImage;
import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModulePool;
/**
* Implement this interface to develop your own image layout. First the jimage
@@ -45,7 +45,7 @@ public interface ImageBuilder {
* @param release the release properties
* @throws PluginException
*/
- public default void storeFiles(Pool content, Properties release) {
+ public default void storeFiles(ModulePool content, Properties release) {
storeFiles(content);
}
@@ -55,7 +55,7 @@ public interface ImageBuilder {
* @param content Pool of module content.
* @throws PluginException
*/
- public default void storeFiles(Pool content) {
+ public default void storeFiles(ModulePool content) {
throw new UnsupportedOperationException("storeFiles");
}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java
index e0347e52a21..f765be2919b 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java
@@ -44,12 +44,11 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import jdk.tools.jlink.internal.Archive.Entry;
import jdk.tools.jlink.internal.Archive.Entry.EntryType;
-import jdk.tools.jlink.internal.PoolImpl.CompressedModuleData;
+import jdk.tools.jlink.internal.ModulePoolImpl.CompressedModuleData;
import jdk.tools.jlink.plugin.ExecutableImage;
import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModulePool;
+import jdk.tools.jlink.plugin.ModuleEntry;
/**
* An image (native endian.)
@@ -145,7 +144,7 @@ public final class ImageFileCreator {
}));
ByteOrder order = ByteOrder.nativeOrder();
BasicImageWriter writer = new BasicImageWriter(order);
- PoolImpl pool = createPools(archives, entriesForModule, order, writer);
+ ModulePoolImpl pool = createPools(archives, entriesForModule, order, writer);
try (OutputStream fos = Files.newOutputStream(jimageFile);
BufferedOutputStream bos = new BufferedOutputStream(fos);
DataOutputStream out = new DataOutputStream(bos)) {
@@ -163,9 +162,9 @@ public final class ImageFileCreator {
ByteOrder byteOrder)
throws IOException {
BasicImageWriter writer = new BasicImageWriter(byteOrder);
- PoolImpl allContent = createPools(archives,
+ ModulePoolImpl allContent = createPools(archives,
entriesForModule, byteOrder, writer);
- PoolImpl result = generateJImage(allContent,
+ ModulePoolImpl result = generateJImage(allContent,
writer, plugins, plugins.getJImageFileOutputStream());
//Handle files.
@@ -176,12 +175,12 @@ public final class ImageFileCreator {
}
}
- private static PoolImpl generateJImage(PoolImpl allContent,
+ private static ModulePoolImpl generateJImage(ModulePoolImpl allContent,
BasicImageWriter writer,
ImagePluginStack pluginSupport,
DataOutputStream out
) throws IOException {
- PoolImpl resultResources;
+ ModulePoolImpl resultResources;
try {
resultResources = pluginSupport.visitResources(allContent);
} catch (PluginException pe) {
@@ -190,14 +189,14 @@ public final class ImageFileCreator {
throw new IOException(ex);
}
Set duplicates = new HashSet<>();
- long offset = 0;
+ long[] offset = new long[1];
- List content = new ArrayList<>();
+ List content = new ArrayList<>();
List paths = new ArrayList<>();
// the order of traversing the resources and the order of
// the module content being written must be the same
- for (ModuleData res : resultResources.getContent()) {
- if (res.getType().equals(ModuleDataType.CLASS_OR_RESOURCE)) {
+ resultResources.entries().forEach(res -> {
+ if (res.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) {
String path = res.getPath();
content.add(res);
long uncompressedSize = res.getLength();
@@ -216,24 +215,24 @@ public final class ImageFileCreator {
// TODO Need to hang bytes on resource and write
// from resource not zip.
// Skipping resource throws off writing from zip.
- offset += onFileSize;
- continue;
+ offset[0] += onFileSize;
+ return;
}
duplicates.add(path);
- writer.addLocation(path, offset, compressedSize, uncompressedSize);
+ writer.addLocation(path, offset[0], compressedSize, uncompressedSize);
paths.add(path);
- offset += onFileSize;
+ offset[0] += onFileSize;
}
- }
+ });
- ImageResourcesTree tree = new ImageResourcesTree(offset, writer, paths);
+ ImageResourcesTree tree = new ImageResourcesTree(offset[0], writer, paths);
// write header and indices
byte[] bytes = writer.getBytes();
out.write(bytes, 0, bytes.length);
// write module content
- for (ModuleData res : content) {
+ for (ModuleEntry res : content) {
byte[] buf = res.getBytes();
out.write(buf, 0, buf.length);
}
@@ -245,26 +244,26 @@ public final class ImageFileCreator {
return resultResources;
}
- private static Pool.ModuleDataType mapImageFileType(EntryType type) {
+ private static ModuleEntry.Type mapImageFileType(EntryType type) {
switch(type) {
case CONFIG: {
- return Pool.ModuleDataType.CONFIG;
+ return ModuleEntry.Type.CONFIG;
}
case NATIVE_CMD: {
- return Pool.ModuleDataType.NATIVE_CMD;
+ return ModuleEntry.Type.NATIVE_CMD;
}
case NATIVE_LIB: {
- return Pool.ModuleDataType.NATIVE_LIB;
+ return ModuleEntry.Type.NATIVE_LIB;
}
}
return null;
}
- private static PoolImpl createPools(Set archives,
+ private static ModulePoolImpl createPools(Set archives,
Map> entriesForModule,
ByteOrder byteOrder,
BasicImageWriter writer) throws IOException {
- PoolImpl resources = new PoolImpl(byteOrder, new StringTable() {
+ ModulePoolImpl resources = new ModulePoolImpl(byteOrder, new StringTable() {
@Override
public int addString(String str) {
@@ -291,7 +290,7 @@ public final class ImageFileCreator {
path = "/" + mn + "/" + path;
}
try {
- resources.add(Pool.newResource(path, bytes));
+ resources.add(ModuleEntry.create(path, bytes));
} catch (Exception ex) {
throw new IOException(ex);
}
@@ -300,7 +299,7 @@ public final class ImageFileCreator {
try {
// Entry.path() contains the kind of file native, conf, bin, ...
// Keep it to avoid naming conflict (eg: native/jvm.cfg and config/jvm.cfg
- resources.add(Pool.newImageFile(mn,
+ resources.add(ModuleEntry.create(mn,
"/" + mn + "/" + entry.path(), mapImageFileType(entry.type()),
entry.stream(), entry.size()));
} catch (Exception ex) {
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginConfiguration.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginConfiguration.java
index 7bd631a8c72..08ff3cb7e64 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginConfiguration.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginConfiguration.java
@@ -28,22 +28,17 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Objects;
-import java.util.Properties;
import jdk.tools.jlink.plugin.ExecutableImage;
import jdk.tools.jlink.builder.ImageBuilder;
import jdk.tools.jlink.Jlink;
import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.PluginContext;
import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Plugin.CATEGORY;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.Plugin.Category;
+import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.PostProcessorPlugin;
import jdk.tools.jlink.plugin.TransformerPlugin;
@@ -52,17 +47,18 @@ import jdk.tools.jlink.plugin.TransformerPlugin;
*/
public final class ImagePluginConfiguration {
- private static final List CATEGORIES_ORDER = new ArrayList<>();
+ private static final List CATEGORIES_ORDER = new ArrayList<>();
static {
- CATEGORIES_ORDER.add(Plugin.CATEGORY.FILTER);
- CATEGORIES_ORDER.add(Plugin.CATEGORY.TRANSFORMER);
- CATEGORIES_ORDER.add(Plugin.CATEGORY.MODULEINFO_TRANSFORMER);
- CATEGORIES_ORDER.add(Plugin.CATEGORY.SORTER);
- CATEGORIES_ORDER.add(Plugin.CATEGORY.COMPRESSOR);
- CATEGORIES_ORDER.add(Plugin.CATEGORY.VERIFIER);
- CATEGORIES_ORDER.add(Plugin.CATEGORY.PROCESSOR);
- CATEGORIES_ORDER.add(Plugin.CATEGORY.PACKAGER);
+ CATEGORIES_ORDER.add(Plugin.Category.FILTER);
+ CATEGORIES_ORDER.add(Plugin.Category.TRANSFORMER);
+ CATEGORIES_ORDER.add(Plugin.Category.MODULEINFO_TRANSFORMER);
+ CATEGORIES_ORDER.add(Plugin.Category.SORTER);
+ CATEGORIES_ORDER.add(Plugin.Category.COMPRESSOR);
+ CATEGORIES_ORDER.add(Plugin.Category.METAINFO_ADDER);
+ CATEGORIES_ORDER.add(Plugin.Category.VERIFIER);
+ CATEGORIES_ORDER.add(Plugin.Category.PROCESSOR);
+ CATEGORIES_ORDER.add(Plugin.Category.PACKAGER);
}
private ImagePluginConfiguration() {
@@ -76,8 +72,8 @@ public final class ImagePluginConfiguration {
if (pluginsConfiguration == null) {
return new ImagePluginStack();
}
- Map> plugins = new LinkedHashMap<>();
- for (Plugin.CATEGORY cat : CATEGORIES_ORDER) {
+ Map> plugins = new LinkedHashMap<>();
+ for (Plugin.Category cat : CATEGORIES_ORDER) {
plugins.put(cat, new ArrayList<>());
}
@@ -89,7 +85,7 @@ public final class ImagePluginConfiguration {
+ " added more than once to stack ");
}
seen.add(plug.getName());
- CATEGORY category = Utils.getCategory(plug);
+ Category category = Utils.getCategory(plug);
if (category == null) {
throw new PluginException("Invalid category for "
+ plug.getName());
@@ -100,10 +96,10 @@ public final class ImagePluginConfiguration {
List transformerPlugins = new ArrayList<>();
List postProcessingPlugins = new ArrayList<>();
- for (Entry> entry : plugins.entrySet()) {
+ for (Entry> entry : plugins.entrySet()) {
// Sort according to plugin constraints
List orderedPlugins = PluginOrderingGraph.sort(entry.getValue());
- CATEGORY category = entry.getKey();
+ Category category = entry.getKey();
for (Plugin p : orderedPlugins) {
if (Utils.isPostProcessor(category)) {
@SuppressWarnings("unchecked")
@@ -143,14 +139,13 @@ public final class ImagePluginConfiguration {
}
@Override
- public void storeFiles(Pool files) {
+ public void storeFiles(ModulePool files) {
throw new PluginException("No directory setup to store files");
}
};
}
- PluginContext ctxt = pluginsConfiguration.getPluginContext();
return new ImagePluginStack(builder, transformerPlugins,
- lastSorter, postProcessingPlugins, ctxt);
+ lastSorter, postProcessingPlugins);
}
}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java
index 6a5db82ccdf..24b8aeb632d 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java
@@ -37,20 +37,21 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
-import java.util.Properties;
+import java.util.Optional;
import java.util.Set;
+import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import jdk.internal.jimage.decompressor.Decompressor;
import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.PluginContext;
import jdk.tools.jlink.plugin.ExecutableImage;
import jdk.tools.jlink.builder.ImageBuilder;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModulePool;
+import jdk.tools.jlink.plugin.LinkModule;
+import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.PostProcessorPlugin;
/**
@@ -64,9 +65,9 @@ public final class ImagePluginStack {
ExecutableImage retrieve(ImagePluginStack stack) throws IOException;
}
- public static final class OrderedResourcePool extends PoolImpl {
+ public static final class OrderedResourcePool extends ModulePoolImpl {
- private final List orderedList = new ArrayList<>();
+ private final List orderedList = new ArrayList<>();
public OrderedResourcePool(ByteOrder order, StringTable table) {
super(order, table);
@@ -78,22 +79,22 @@ public final class ImagePluginStack {
* @param resource The Resource to add.
*/
@Override
- public void add(ModuleData resource) {
+ public void add(ModuleEntry resource) {
super.add(resource);
orderedList.add(resource);
}
- List getOrderedList() {
+ List getOrderedList() {
return Collections.unmodifiableList(orderedList);
}
}
- private final static class CheckOrderResourcePool extends PoolImpl {
+ private final static class CheckOrderResourcePool extends ModulePoolImpl {
- private final List orderedList;
+ private final List orderedList;
private int currentIndex;
- public CheckOrderResourcePool(ByteOrder order, List orderedList, StringTable table) {
+ public CheckOrderResourcePool(ByteOrder order, List orderedList, StringTable table) {
super(order, table);
this.orderedList = orderedList;
}
@@ -104,8 +105,8 @@ public final class ImagePluginStack {
* @param resource The Resource to add.
*/
@Override
- public void add(ModuleData resource) {
- ModuleData ordered = orderedList.get(currentIndex);
+ public void add(ModuleEntry resource) {
+ ModuleEntry ordered = orderedList.get(currentIndex);
if (!resource.equals(ordered)) {
throw new PluginException("Resource " + resource.getPath() + " not in the right order");
}
@@ -166,26 +167,16 @@ public final class ImagePluginStack {
private final List resourcePrevisitors = new ArrayList<>();
private final ImageBuilder imageBuilder;
- private final Properties release;
public ImagePluginStack() {
this(null, Collections.emptyList(), null,
- Collections.emptyList(), null);
+ Collections.emptyList());
}
public ImagePluginStack(ImageBuilder imageBuilder,
List contentPlugins,
Plugin lastSorter,
List postprocessingPlugins) {
- this(imageBuilder, contentPlugins, lastSorter,
- postprocessingPlugins, null);
- }
-
- public ImagePluginStack(ImageBuilder imageBuilder,
- List contentPlugins,
- Plugin lastSorter,
- List postprocessingPlugins,
- PluginContext ctxt) {
Objects.requireNonNull(contentPlugins);
this.lastSorter = lastSorter;
for (TransformerPlugin p : contentPlugins) {
@@ -200,7 +191,6 @@ public final class ImagePluginStack {
this.postProcessingPlugins.add(p);
}
this.imageBuilder = imageBuilder;
- this.release = ctxt != null? ctxt.getReleaseProperties() : new Properties();
}
public void operate(ImageProvider provider) throws Exception {
@@ -231,12 +221,12 @@ public final class ImagePluginStack {
* @return The result of the visit.
* @throws IOException
*/
- public PoolImpl visitResources(PoolImpl resources)
+ public ModulePoolImpl visitResources(ModulePoolImpl resources)
throws Exception {
Objects.requireNonNull(resources);
resources.setReadOnly();
if (resources.isEmpty()) {
- return new PoolImpl(resources.getByteOrder(),
+ return new ModulePoolImpl(resources.getByteOrder(),
resources.getStringTable());
}
PreVisitStrings previsit = new PreVisitStrings();
@@ -250,11 +240,11 @@ public final class ImagePluginStack {
resources.getStringTable().addString(s);
}
- PoolImpl current = resources;
- List frozenOrder = null;
+ ModulePoolImpl current = resources;
+ List frozenOrder = null;
for (TransformerPlugin p : contentPlugins) {
current.setReadOnly();
- PoolImpl output = null;
+ ModulePoolImpl output = null;
if (p == lastSorter) {
if (frozenOrder != null) {
throw new Exception("Order of resources is already frozen. Plugin "
@@ -268,7 +258,7 @@ public final class ImagePluginStack {
output = new CheckOrderResourcePool(current.getByteOrder(),
frozenOrder, resources.getStringTable());
} else {
- output = new PoolImpl(current.getByteOrder(),
+ output = new ModulePoolImpl(current.getByteOrder(),
resources.getStringTable());
}
}
@@ -287,15 +277,15 @@ public final class ImagePluginStack {
}
/**
- * This pool wrap the original pool and automatically uncompress moduledata
+ * This pool wrap the original pool and automatically uncompress ModuleEntry
* if needed.
*/
- private class LastPool extends Pool {
- private class LastModule implements Module {
+ private class LastPool implements ModulePool {
+ private class LastModule implements LinkModule {
- private final Module module;
+ final LinkModule module;
- LastModule(Module module) {
+ LastModule(LinkModule module) {
this.module = module;
}
@@ -305,9 +295,9 @@ public final class ImagePluginStack {
}
@Override
- public ModuleData get(String path) {
- ModuleData d = module.get(path);
- return getUncompressed(d);
+ public Optional findEntry(String path) {
+ Optional d = module.findEntry(path);
+ return d.isPresent()? Optional.of(getUncompressed(d.get())) : Optional.empty();
}
@Override
@@ -316,7 +306,7 @@ public final class ImagePluginStack {
}
@Override
- public void add(ModuleData data) {
+ public void add(ModuleEntry data) {
throw new PluginException("pool is readonly");
}
@@ -331,19 +321,24 @@ public final class ImagePluginStack {
}
@Override
- public Collection getContent() {
- List lst = new ArrayList<>();
- for(ModuleData md : module.getContent()) {
+ public Stream entries() {
+ List lst = new ArrayList<>();
+ module.entries().forEach(md -> {
lst.add(getUncompressed(md));
- }
- return lst;
+ });
+ return lst.stream();
+ }
+
+ @Override
+ public int getEntryCount() {
+ return module.getEntryCount();
}
}
- private final PoolImpl pool;
+ private final ModulePoolImpl pool;
Decompressor decompressor = new Decompressor();
- Collection content;
+ Collection content;
- LastPool(PoolImpl pool) {
+ LastPool(ModulePoolImpl pool) {
this.pool = pool;
}
@@ -353,23 +348,14 @@ public final class ImagePluginStack {
}
@Override
- public void add(ModuleData resource) {
+ public void add(ModuleEntry resource) {
throw new PluginException("pool is readonly");
}
- /**
- * Retrieves the module of the provided name.
- *
- * @param name The module name
- * @return the module or null if the module doesn't exist.
- */
@Override
- public Module getModule(String name) {
- Module module = pool.getModule(name);
- if (module != null) {
- module = new LastModule(module);
- }
- return module;
+ public Optional findModule(String name) {
+ Optional module = pool.findModule(name);
+ return module.isPresent()? Optional.of(new LastModule(module.get())) : Optional.empty();
}
/**
@@ -378,45 +364,55 @@ public final class ImagePluginStack {
* @return The collection of modules.
*/
@Override
- public Collection getModules() {
- List modules = new ArrayList<>();
- for (Module m : pool.getModules()) {
+ public Stream extends LinkModule> modules() {
+ List modules = new ArrayList<>();
+ pool.modules().forEach(m -> {
modules.add(new LastModule(m));
- }
- return modules;
+ });
+ return modules.stream();
+ }
+
+ @Override
+ public int getModuleCount() {
+ return pool.getModuleCount();
}
/**
* Get all resources contained in this pool instance.
*
- * @return The collection of resources;
+ * @return The stream of resources;
*/
@Override
- public Collection getContent() {
+ public Stream extends ModuleEntry> entries() {
if (content == null) {
content = new ArrayList<>();
- for (ModuleData md : pool.getContent()) {
+ pool.entries().forEach(md -> {
content.add(getUncompressed(md));
- }
+ });
}
- return content;
+ return content.stream();
+ }
+
+ @Override
+ public int getEntryCount() {
+ return pool.getEntryCount();
}
/**
* Get the resource for the passed path.
*
* @param path A resource path
- * @return A Resource instance or null if the resource is not found
+ * @return A Resource instance if the resource is found
*/
@Override
- public ModuleData get(String path) {
+ public Optional findEntry(String path) {
Objects.requireNonNull(path);
- Pool.ModuleData res = pool.get(path);
- return getUncompressed(res);
+ Optional res = pool.findEntry(path);
+ return res.isPresent()? Optional.of(getUncompressed(res.get())) : Optional.empty();
}
@Override
- public boolean contains(ModuleData res) {
+ public boolean contains(ModuleEntry res) {
return pool.contains(res);
}
@@ -426,8 +422,8 @@ public final class ImagePluginStack {
}
@Override
- public void visit(Visitor visitor, Pool output) {
- pool.visit(visitor, output);
+ public void transformAndCopy(Function visitor, ModulePool output) {
+ pool.transformAndCopy(visitor, output);
}
@Override
@@ -435,14 +431,19 @@ public final class ImagePluginStack {
return pool.getByteOrder();
}
- private ModuleData getUncompressed(ModuleData res) {
+ @Override
+ public Map getReleaseProperties() {
+ return Collections.unmodifiableMap(pool.getReleaseProperties());
+ }
+
+ private ModuleEntry getUncompressed(ModuleEntry res) {
if (res != null) {
- if (res instanceof PoolImpl.CompressedModuleData) {
+ if (res instanceof ModulePoolImpl.CompressedModuleData) {
try {
byte[] bytes = decompressor.decompressResource(getByteOrder(),
(int offset) -> pool.getStringTable().getString(offset),
res.getBytes());
- res = Pool.newResource(res.getPath(),
+ res = ModuleEntry.create(res.getPath(),
new ByteArrayInputStream(bytes),
bytes.length);
} catch (IOException ex) {
@@ -462,20 +463,24 @@ public final class ImagePluginStack {
* @param writer
* @throws java.lang.Exception
*/
- public void storeFiles(PoolImpl original, PoolImpl transformed,
+ public void storeFiles(ModulePoolImpl original, ModulePoolImpl transformed,
BasicImageWriter writer)
throws Exception {
Objects.requireNonNull(original);
- try {
- // fill release information available from transformed "java.base" module!
- ModuleDescriptor desc = transformed.getModule("java.base").getDescriptor();
- desc.osName().ifPresent(s -> release.put("OS_NAME", s));
- desc.osVersion().ifPresent(s -> release.put("OS_VERSION", s));
- desc.osArch().ifPresent(s -> release.put("OS_ARCH", s));
- } catch (Exception ignored) {
- }
+ Objects.requireNonNull(transformed);
+ Optional javaBase = transformed.findModule("java.base");
+ javaBase.ifPresent(mod -> {
+ try {
+ Map release = transformed.getReleaseProperties();
+ // fill release information available from transformed "java.base" module!
+ ModuleDescriptor desc = mod.getDescriptor();
+ desc.osName().ifPresent(s -> release.put("OS_NAME", s));
+ desc.osVersion().ifPresent(s -> release.put("OS_VERSION", s));
+ desc.osArch().ifPresent(s -> release.put("OS_ARCH", s));
+ } catch (Exception ignored) {}
+ });
- imageBuilder.storeFiles(new LastPool(transformed), release);
+ imageBuilder.storeFiles(new LastPool(transformed));
}
public ExecutableImage getExecutableImage() throws IOException {
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryImpl.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryImpl.java
new file mode 100644
index 00000000000..30c07a3b2d7
--- /dev/null
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryImpl.java
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.tools.jlink.internal;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UncheckedIOException;
+import java.util.Objects;
+import jdk.tools.jlink.plugin.ModuleEntry;
+
+/**
+ * A LinkModuleEntry is the elementary unit of data inside an image. It is
+ * generally a file. e.g.: a java class file, a resource file, a shared library,
+ * ...
+ *
+ * A LinkModuleEntry is identified by a path of the form:
+ *
+ * - For jimage content: /{module name}/{package1}/.../{packageN}/{file
+ * name}
+ * - For other files (shared lib, launchers, config, ...):/{module name}/
+ * {@literal bin|conf|native}/{dir1}>/.../{dirN}/{file name}
+ *
+ */
+public class ModuleEntryImpl implements ModuleEntry {
+
+ private final Type type;
+ private final String path;
+ private final String module;
+ private final long length;
+ private final InputStream stream;
+ private byte[] buffer;
+
+ /**
+ * Create a new LinkModuleEntry.
+ *
+ * @param module The module name.
+ * @param path The data path identifier.
+ * @param type The data type.
+ * @param stream The data content stream.
+ * @param length The stream length.
+ */
+ public ModuleEntryImpl(String module, String path, Type type, InputStream stream, long length) {
+ Objects.requireNonNull(module);
+ Objects.requireNonNull(path);
+ Objects.requireNonNull(type);
+ Objects.requireNonNull(stream);
+ this.path = path;
+ this.type = type;
+ this.module = module;
+ this.stream = stream;
+ this.length = length;
+ }
+
+ /**
+ * The LinkModuleEntry module name.
+ *
+ * @return The module name.
+ */
+ @Override
+ public final String getModule() {
+ return module;
+ }
+
+ /**
+ * The LinkModuleEntry path.
+ *
+ * @return The module path.
+ */
+ @Override
+ public final String getPath() {
+ return path;
+ }
+
+ /**
+ * The LinkModuleEntry's type.
+ *
+ * @return The data type.
+ */
+ @Override
+ public final Type getType() {
+ return type;
+ }
+
+ /**
+ * The LinkModuleEntry content as an array of byte.
+ *
+ * @return An Array of bytes.
+ */
+ @Override
+ public byte[] getBytes() {
+ if (buffer == null) {
+ try (InputStream is = stream) {
+ buffer = is.readAllBytes();
+ } catch (IOException ex) {
+ throw new UncheckedIOException(ex);
+ }
+ }
+ return buffer;
+ }
+
+ /**
+ * The LinkModuleEntry content length.
+ *
+ * @return The length.
+ */
+ @Override
+ public long getLength() {
+ return length;
+ }
+
+ /**
+ * The LinkModuleEntry stream.
+ *
+ * @return The module data stream.
+ */
+ @Override
+ public InputStream stream() {
+ return stream;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 89 * hash + Objects.hashCode(this.path);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof ModuleEntryImpl)) {
+ return false;
+ }
+ ModuleEntryImpl f = (ModuleEntryImpl) other;
+ return f.path.equals(path);
+ }
+
+ @Override
+ public String toString() {
+ return getPath();
+ }
+}
\ No newline at end of file
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java
new file mode 100644
index 00000000000..a572fa48637
--- /dev/null
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java
@@ -0,0 +1,421 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.tools.jlink.internal;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.lang.module.ModuleDescriptor;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.stream.Stream;
+import jdk.internal.jimage.decompressor.CompressedResourceHeader;
+import jdk.tools.jlink.plugin.ModulePool;
+import jdk.tools.jlink.plugin.LinkModule;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.PluginException;
+import jdk.tools.jlink.internal.plugins.FileCopierPlugin;
+
+/**
+ * Pool of module data.
+ */
+public class ModulePoolImpl implements ModulePool {
+
+ private class ModuleImpl implements LinkModule {
+
+ final Map moduleContent = new LinkedHashMap<>();
+ private ModuleDescriptor descriptor;
+ final String name;
+
+ private ModuleImpl(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public Optional findEntry(String path) {
+ if (!path.startsWith("/")) {
+ path = "/" + path;
+ }
+ if (!path.startsWith("/" + name)) {
+ path = "/" + name + path;
+ }
+ return Optional.ofNullable(moduleContent.get(path));
+ }
+
+ @Override
+ public ModuleDescriptor getDescriptor() {
+ if (descriptor == null) {
+ String p = "/" + name + "/module-info.class";
+ Optional content = findEntry(p);
+ if (!content.isPresent()) {
+ throw new PluginException("No module-info for " + name
+ + " module");
+ }
+ ByteBuffer bb = ByteBuffer.wrap(content.get().getBytes());
+ descriptor = ModuleDescriptor.read(bb);
+ }
+ return descriptor;
+ }
+
+ @Override
+ public void add(ModuleEntry data) {
+ if (isReadOnly()) {
+ throw new PluginException("LinkConfiguration is readonly");
+ }
+ Objects.requireNonNull(data);
+ if (!data.getModule().equals(name)) {
+ throw new PluginException("Can't add resource " + data.getPath()
+ + " to module " + name);
+ }
+ ModulePoolImpl.this.add(data);
+ }
+
+ @Override
+ public Set getAllPackages() {
+ Set pkgs = new HashSet<>();
+ moduleContent.values().stream().filter(m -> m.getType().
+ equals(ModuleEntry.Type.CLASS_OR_RESOURCE)).forEach(res -> {
+ // Module metadata only contains packages with .class files
+ if (ImageFileCreator.isClassPackage(res.getPath())) {
+ String[] split = ImageFileCreator.splitPath(res.getPath());
+ String pkg = split[1];
+ if (pkg != null && !pkg.isEmpty()) {
+ pkgs.add(pkg);
+ }
+ }
+ });
+ return pkgs;
+ }
+
+ @Override
+ public String toString() {
+ return getName();
+ }
+
+ @Override
+ public Stream extends ModuleEntry> entries() {
+ return moduleContent.values().stream();
+ }
+
+ @Override
+ public int getEntryCount() {
+ return moduleContent.values().size();
+ }
+ }
+
+ private final Map resources = new LinkedHashMap<>();
+ private final Map modules = new LinkedHashMap<>();
+ private final ModuleImpl fileCopierModule = new ModuleImpl(FileCopierPlugin.FAKE_MODULE);
+ private Map releaseProps = new HashMap<>();
+
+ private final ByteOrder order;
+
+ private boolean isReadOnly;
+ private final StringTable table;
+
+ public ModulePoolImpl() {
+ this(ByteOrder.nativeOrder());
+ }
+
+ public ModulePoolImpl(ByteOrder order) {
+ this(order, new StringTable() {
+
+ @Override
+ public int addString(String str) {
+ return -1;
+ }
+
+ @Override
+ public String getString(int id) {
+ return null;
+ }
+ });
+ }
+
+ public ModulePoolImpl(ByteOrder order, StringTable table) {
+ this.order = order;
+ this.table = table;
+ }
+
+ /**
+ * Add a ModuleEntry.
+ *
+ * @param data The ModuleEntry to add.
+ */
+ @Override
+ public void add(ModuleEntry data) {
+ if (isReadOnly()) {
+ throw new PluginException("LinkConfiguration is readonly");
+ }
+ Objects.requireNonNull(data);
+ if (resources.get(data.getPath()) != null) {
+ throw new PluginException("Resource " + data.getPath()
+ + " already present");
+ }
+ String modulename = data.getModule();
+ ModuleImpl m = modules.get(modulename);
+ // ## TODO: FileCopierPlugin should not add content to a module
+ // FAKE_MODULE is not really a module to be added in the image
+ if (FileCopierPlugin.FAKE_MODULE.equals(modulename)) {
+ m = fileCopierModule;
+ }
+ if (m == null) {
+ m = new ModuleImpl(modulename);
+ modules.put(modulename, m);
+ }
+ resources.put(data.getPath(), data);
+ m.moduleContent.put(data.getPath(), data);
+ }
+
+ /**
+ * Retrieves the module for the provided name.
+ *
+ * @param name The module name
+ * @return the module of matching name, if found
+ */
+ @Override
+ public Optional findModule(String name) {
+ Objects.requireNonNull(name);
+ return Optional.ofNullable(modules.get(name));
+ }
+
+ /**
+ * The stream of modules contained in this LinkConfiguration.
+ *
+ * @return The stream of modules.
+ */
+ @Override
+ public Stream extends LinkModule> modules() {
+ return modules.values().stream();
+ }
+
+ /**
+ * Return the number of LinkModule count in this LinkConfiguration.
+ *
+ * @return the module count.
+ */
+ @Override
+ public int getModuleCount() {
+ return modules.size();
+ }
+
+ /**
+ * Get all ModuleEntry contained in this LinkConfiguration instance.
+ *
+ * @return The stream of LinkModuleEntries.
+ */
+ @Override
+ public Stream extends ModuleEntry> entries() {
+ return resources.values().stream();
+ }
+
+ /**
+ * Return the number of ModuleEntry count in this LinkConfiguration.
+ *
+ * @return the entry count.
+ */
+ @Override
+ public int getEntryCount() {
+ return resources.values().size();
+ }
+
+ /**
+ * Get the ModuleEntry for the passed path.
+ *
+ * @param path A data path
+ * @return A ModuleEntry instance or null if the data is not found
+ */
+ @Override
+ public Optional findEntry(String path) {
+ Objects.requireNonNull(path);
+ return Optional.ofNullable(resources.get(path));
+ }
+
+ /**
+ * Check if the LinkConfiguration contains the given ModuleEntry.
+ *
+ * @param data The module data to check existence for.
+ * @return The module data or null if not found.
+ */
+ @Override
+ public boolean contains(ModuleEntry data) {
+ Objects.requireNonNull(data);
+ return findEntry(data.getPath()).isPresent();
+ }
+
+ /**
+ * Check if the LinkConfiguration contains some content at all.
+ *
+ * @return True, no content, false otherwise.
+ */
+ @Override
+ public boolean isEmpty() {
+ return resources.isEmpty();
+ }
+
+ /**
+ * Visit each ModuleEntry in this LinkConfiguration to transform it and
+ * copy the transformed ModuleEntry to the output LinkConfiguration.
+ *
+ * @param transform The function called for each ModuleEntry found in
+ * the LinkConfiguration. The transform function should return a
+ * ModuleEntry instance which will be added to the output or it should
+ * return null if the passed ModuleEntry is to be ignored for the
+ * output.
+ *
+ * @param output The LinkConfiguration to be filled with Visitor returned
+ * ModuleEntry.
+ */
+ @Override
+ public void transformAndCopy(Function transform,
+ ModulePool output) {
+ entries().forEach(resource -> {
+ ModuleEntry res = transform.apply(resource);
+ if (res != null) {
+ output.add(res);
+ }
+ });
+ }
+
+ /**
+ * The ByteOrder currently in use when generating the jimage file.
+ *
+ * @return The ByteOrder.
+ */
+ @Override
+ public ByteOrder getByteOrder() {
+ return order;
+ }
+
+ @Override
+ public Map getReleaseProperties() {
+ return isReadOnly()? Collections.unmodifiableMap(releaseProps) : releaseProps;
+ }
+
+ public StringTable getStringTable() {
+ return table;
+ }
+
+ /**
+ * Make this Resources instance read-only. No resource can be added.
+ */
+ public void setReadOnly() {
+ isReadOnly = true;
+ }
+
+ /**
+ * Read only state.
+ *
+ * @return true if readonly false otherwise.
+ */
+ @Override
+ public boolean isReadOnly() {
+ return isReadOnly;
+ }
+
+ /**
+ * A resource that has been compressed.
+ */
+ public static final class CompressedModuleData extends ModuleEntryImpl {
+
+ final long uncompressed_size;
+
+ private CompressedModuleData(String module, String path,
+ InputStream stream, long size,
+ long uncompressed_size) {
+ super(module, path, ModuleEntry.Type.CLASS_OR_RESOURCE, stream, size);
+ this.uncompressed_size = uncompressed_size;
+ }
+
+ public long getUncompressedSize() {
+ return uncompressed_size;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof CompressedModuleData)) {
+ return false;
+ }
+ CompressedModuleData f = (CompressedModuleData) other;
+ return f.getPath().equals(getPath());
+ }
+
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
+ }
+
+ public static CompressedModuleData newCompressedResource(ModuleEntry original,
+ ByteBuffer compressed,
+ String plugin, String pluginConfig, StringTable strings,
+ ByteOrder order) {
+ Objects.requireNonNull(original);
+ Objects.requireNonNull(compressed);
+ Objects.requireNonNull(plugin);
+
+ boolean isTerminal = !(original instanceof CompressedModuleData);
+ long uncompressed_size = original.getLength();
+ if (original instanceof CompressedModuleData) {
+ CompressedModuleData comp = (CompressedModuleData) original;
+ uncompressed_size = comp.getUncompressedSize();
+ }
+ int nameOffset = strings.addString(plugin);
+ int configOffset = -1;
+ if (pluginConfig != null) {
+ configOffset = strings.addString(plugin);
+ }
+ CompressedResourceHeader rh
+ = new CompressedResourceHeader(compressed.limit(), original.getLength(),
+ nameOffset, configOffset, isTerminal);
+ // Merge header with content;
+ byte[] h = rh.getBytes(order);
+ ByteBuffer bb = ByteBuffer.allocate(compressed.limit() + h.length);
+ bb.order(order);
+ bb.put(h);
+ bb.put(compressed);
+ byte[] contentWithHeader = bb.array();
+
+ CompressedModuleData compressedResource
+ = new CompressedModuleData(original.getModule(), original.getPath(),
+ new ByteArrayInputStream(contentWithHeader),
+ contentWithHeader.length, uncompressed_size);
+ return compressedResource;
+ }
+
+}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PluginContextImpl.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PluginContextImpl.java
deleted file mode 100644
index 7fe7dcea36e..00000000000
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PluginContextImpl.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.tools.jlink.internal;
-
-import java.util.Properties;
-
-import jdk.tools.jlink.plugin.PluginContext;
-
-public final class PluginContextImpl implements PluginContext {
- private final Properties releaseProps = new Properties();
-
- public Properties getReleaseProperties() {
- return releaseProps;
- }
-}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PoolImpl.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PoolImpl.java
deleted file mode 100644
index 2b1dd827bae..00000000000
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PoolImpl.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.tools.jlink.internal;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.Objects;
-import jdk.internal.jimage.decompressor.CompressedResourceHeader;
-import jdk.tools.jlink.plugin.Pool;
-
-/**
- * Pool of module data.
- */
-public class PoolImpl extends Pool {
-
- /**
- * A resource that has been compressed.
- */
- public static final class CompressedModuleData extends ModuleData {
-
- private final long uncompressed_size;
-
- private CompressedModuleData(String module, String path,
- InputStream stream, long size,
- long uncompressed_size) {
- super(module, path, ModuleDataType.CLASS_OR_RESOURCE, stream, size);
- this.uncompressed_size = uncompressed_size;
- }
-
- public long getUncompressedSize() {
- return uncompressed_size;
- }
-
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof CompressedModuleData)) {
- return false;
- }
- CompressedModuleData f = (CompressedModuleData) other;
- return f.getPath().equals(getPath());
- }
-
- @Override
- public int hashCode() {
- return super.hashCode();
- }
- }
-
- private boolean isReadOnly;
- private final StringTable table;
-
- public PoolImpl() {
- this(ByteOrder.nativeOrder(), new StringTable() {
-
- @Override
- public int addString(String str) {
- return -1;
- }
- @Override
- public String getString(int id) {
- return null;
- }
- });
- }
-
- public PoolImpl(ByteOrder order) {
- this(order, new StringTable() {
-
- @Override
- public int addString(String str) {
- return -1;
- }
- @Override
- public String getString(int id) {
- return null;
- }
- });
- }
-
- public PoolImpl(ByteOrder order, StringTable table) {
- super(order);
- this.table = table;
- }
-
- public StringTable getStringTable() {
- return table;
- }
-
- /**
- * Make this Resources instance read-only. No resource can be added.
- */
- public void setReadOnly() {
- isReadOnly = true;
- }
-
- /**
- * Read only state.
- *
- * @return true if readonly false otherwise.
- */
- @Override
- public boolean isReadOnly() {
- return isReadOnly;
- }
-
- public static CompressedModuleData newCompressedResource(ModuleData original,
- ByteBuffer compressed,
- String plugin, String pluginConfig, StringTable strings,
- ByteOrder order) {
- Objects.requireNonNull(original);
- Objects.requireNonNull(compressed);
- Objects.requireNonNull(plugin);
-
- boolean isTerminal = !(original instanceof CompressedModuleData);
- long uncompressed_size = original.getLength();
- if (original instanceof CompressedModuleData) {
- CompressedModuleData comp = (CompressedModuleData) original;
- uncompressed_size = comp.getUncompressedSize();
- }
- int nameOffset = strings.addString(plugin);
- int configOffset = -1;
- if (pluginConfig != null) {
- configOffset = strings.addString(plugin);
- }
- CompressedResourceHeader rh
- = new CompressedResourceHeader(compressed.limit(), original.getLength(),
- nameOffset, configOffset, isTerminal);
- // Merge header with content;
- byte[] h = rh.getBytes(order);
- ByteBuffer bb = ByteBuffer.allocate(compressed.limit() + h.length);
- bb.order(order);
- bb.put(h);
- bb.put(compressed);
- byte[] contentWithHeader = bb.array();
-
- CompressedModuleData compressedResource
- = new CompressedModuleData(original.getModule(), original.getPath(),
- new ByteArrayInputStream(contentWithHeader),
- contentWithHeader.length, uncompressed_size);
- return compressedResource;
- }
-
-}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePrevisitor.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePrevisitor.java
index d9c5bab9a61..c8b8bc79ed6 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePrevisitor.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePrevisitor.java
@@ -24,7 +24,7 @@
*/
package jdk.tools.jlink.internal;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModulePool;
/**
* Plugin wishing to pre-visit the resources must implement this interface.
@@ -44,5 +44,5 @@ public interface ResourcePrevisitor {
* usage.
* @throws PluginException
*/
- public void previsit(Pool resources, StringTable strings);
+ public void previsit(ModulePool resources, StringTable strings);
}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java
index 31064ab79d6..b255312bbf4 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java
@@ -52,7 +52,7 @@ import jdk.internal.module.ConfigurableModuleFinder.Phase;
import jdk.tools.jlink.Jlink;
import jdk.tools.jlink.Jlink.PluginsConfiguration;
import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.Plugin.CATEGORY;
+import jdk.tools.jlink.plugin.Plugin.Category;
import jdk.tools.jlink.builder.DefaultImageBuilder;
import jdk.tools.jlink.builder.ImageBuilder;
import jdk.tools.jlink.plugin.PluginException;
@@ -346,7 +346,6 @@ public final class TaskHelper {
}
}
- PluginContextImpl pluginContext = new PluginContextImpl();
List pluginsList = new ArrayList<>();
for (Entry>> entry : pluginToMaps.entrySet()) {
Plugin plugin = entry.getKey();
@@ -356,7 +355,7 @@ public final class TaskHelper {
// we call configure once for each occurrence. It is upto the plugin
// to 'merge' and/or 'override' arguments.
for (Map map : argsMaps) {
- plugin.configure(Collections.unmodifiableMap(map), pluginContext);
+ plugin.configure(Collections.unmodifiableMap(map));
}
if (!Utils.isDisabled(plugin)) {
@@ -371,7 +370,7 @@ public final class TaskHelper {
}
return new Jlink.PluginsConfiguration(pluginsList,
- builder, lastSorter, pluginContext);
+ builder, lastSorter);
}
}
@@ -594,7 +593,7 @@ public final class TaskHelper {
+ ": " + plugin.getClass().getName());
log.println(bundleHelper.getMessage("main.plugin.module")
+ ": " + plugin.getClass().getModule().getName());
- CATEGORY category = Utils.getCategory(plugin);
+ Category category = Utils.getCategory(plugin);
log.println(bundleHelper.getMessage("main.plugin.category")
+ ": " + category.getName());
log.println(bundleHelper.getMessage("main.plugin.state")
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java
index a8a9a45a5f4..0e29969a034 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java
@@ -30,7 +30,6 @@ import java.util.Comparator;
import java.util.List;
import java.util.function.Function;
import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.Plugin.PluginType;
public class Utils {
@@ -50,25 +49,26 @@ public class Utils {
return arguments;
};
- public static boolean isPostProcessor(Plugin.CATEGORY category) {
- return category.equals(Plugin.CATEGORY.VERIFIER)
- || category.equals(Plugin.CATEGORY.PROCESSOR)
- || category.equals(Plugin.CATEGORY.PACKAGER);
+ public static boolean isPostProcessor(Plugin.Category category) {
+ return category.equals(Plugin.Category.VERIFIER)
+ || category.equals(Plugin.Category.PROCESSOR)
+ || category.equals(Plugin.Category.PACKAGER);
}
- public static boolean isPreProcessor(Plugin.CATEGORY category) {
- return category.equals(Plugin.CATEGORY.COMPRESSOR)
- || category.equals(Plugin.CATEGORY.FILTER)
- || category.equals(Plugin.CATEGORY.MODULEINFO_TRANSFORMER)
- || category.equals(Plugin.CATEGORY.SORTER)
- || category.equals(Plugin.CATEGORY.TRANSFORMER);
+ public static boolean isPreProcessor(Plugin.Category category) {
+ return category.equals(Plugin.Category.COMPRESSOR)
+ || category.equals(Plugin.Category.FILTER)
+ || category.equals(Plugin.Category.MODULEINFO_TRANSFORMER)
+ || category.equals(Plugin.Category.SORTER)
+ || category.equals(Plugin.Category.TRANSFORMER)
+ || category.equals(Plugin.Category.METAINFO_ADDER);
}
public static boolean isPostProcessor(Plugin prov) {
if (prov.getType() != null) {
- for (PluginType pt : prov.getType()) {
- if (pt instanceof Plugin.CATEGORY) {
- return isPostProcessor((Plugin.CATEGORY) pt);
+ for (Plugin.Category pt : prov.getType()) {
+ if (pt instanceof Plugin.Category) {
+ return isPostProcessor(pt);
}
}
}
@@ -77,20 +77,20 @@ public class Utils {
public static boolean isPreProcessor(Plugin prov) {
if (prov.getType() != null) {
- for (PluginType pt : prov.getType()) {
- if (pt instanceof Plugin.CATEGORY) {
- return isPreProcessor((Plugin.CATEGORY) pt);
+ for (Plugin.Category pt : prov.getType()) {
+ if (pt instanceof Plugin.Category) {
+ return isPreProcessor(pt);
}
}
}
return false;
}
- public static Plugin.CATEGORY getCategory(Plugin provider) {
+ public static Plugin.Category getCategory(Plugin provider) {
if (provider.getType() != null) {
- for (Plugin.PluginType t : provider.getType()) {
- if (t instanceof Plugin.CATEGORY) {
- return (Plugin.CATEGORY) t;
+ for (Plugin.Category t : provider.getType()) {
+ if (t instanceof Plugin.Category) {
+ return t;
}
}
}
@@ -140,15 +140,15 @@ public class Utils {
}
public static boolean isFunctional(Plugin prov) {
- return prov.getState().contains(Plugin.STATE.FUNCTIONAL);
+ return prov.getState().contains(Plugin.State.FUNCTIONAL);
}
public static boolean isAutoEnabled(Plugin prov) {
- return prov.getState().contains(Plugin.STATE.AUTO_ENABLED);
+ return prov.getState().contains(Plugin.State.AUTO_ENABLED);
}
public static boolean isDisabled(Plugin prov) {
- return prov.getState().contains(Plugin.STATE.DISABLED);
+ return prov.getState().contains(Plugin.State.DISABLED);
}
// is this a builtin (jdk.jlink) plugin?
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java
index e448acd0b1d..874b338c93f 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java
@@ -30,7 +30,7 @@ import jdk.tools.jlink.Jlink;
import jdk.tools.jlink.builder.ImageBuilder;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.builder.*;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModulePool;
import java.io.ByteArrayOutputStream;
import java.io.File;
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java
index aa068f1136e..43eb6f27dec 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java
@@ -26,16 +26,13 @@ package jdk.tools.jlink.internal.plugins;
import java.io.IOException;
import java.io.UncheckedIOException;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
-import java.util.List;
import java.util.Map;
import java.util.Set;
-import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.internal.PoolImpl;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.internal.ModulePoolImpl;
+import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.internal.ImagePluginStack;
import jdk.tools.jlink.internal.ResourcePrevisitor;
@@ -62,10 +59,10 @@ public final class DefaultCompressPlugin implements TransformerPlugin, ResourceP
}
@Override
- public void visit(Pool in, Pool out) {
+ public void visit(ModulePool in, ModulePool out) {
if (ss != null && zip != null) {
- Pool output = new ImagePluginStack.OrderedResourcePool(in.getByteOrder(),
- ((PoolImpl) in).getStringTable());
+ ModulePool output = new ImagePluginStack.OrderedResourcePool(in.getByteOrder(),
+ ((ModulePoolImpl) in).getStringTable());
ss.visit(in, output);
zip.visit(output, out);
} else if (ss != null) {
@@ -76,16 +73,16 @@ public final class DefaultCompressPlugin implements TransformerPlugin, ResourceP
}
@Override
- public void previsit(Pool resources, StringTable strings) {
+ public void previsit(ModulePool resources, StringTable strings) {
if (ss != null) {
ss.previsit(resources, strings);
}
}
@Override
- public Set getType() {
- Set set = new HashSet<>();
- set.add(CATEGORY.COMPRESSOR);
+ public Set getType() {
+ Set set = new HashSet<>();
+ set.add(Category.COMPRESSOR);
return Collections.unmodifiableSet(set);
}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java
index 0271670e4c1..628d8f6346e 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java
@@ -32,8 +32,8 @@ import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;
import jdk.tools.jlink.plugin.TransformerPlugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModulePool;
+import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.internal.Utils;
/**
@@ -51,9 +51,9 @@ public final class ExcludeFilesPlugin implements TransformerPlugin {
}
@Override
- public void visit(Pool in, Pool out) {
- in.visit((file) -> {
- if (!file.getType().equals(ModuleDataType.CLASS_OR_RESOURCE)) {
+ public void visit(ModulePool in, ModulePool out) {
+ in.transformAndCopy((file) -> {
+ if (!file.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) {
file = predicate.test(file.getPath()) ? file : null;
}
return file;
@@ -61,9 +61,9 @@ public final class ExcludeFilesPlugin implements TransformerPlugin {
}
@Override
- public Set getType() {
- Set set = new HashSet<>();
- set.add(CATEGORY.FILTER);
+ public Set getType() {
+ Set set = new HashSet<>();
+ set.add(Category.FILTER);
return Collections.unmodifiableSet(set);
}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java
index 6d4737a4661..626087b76be 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java
@@ -32,7 +32,8 @@ import java.util.Set;
import java.util.function.Predicate;
import jdk.tools.jlink.plugin.PluginException;
import jdk.tools.jlink.plugin.TransformerPlugin;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.internal.Utils;
/**
@@ -50,9 +51,9 @@ public final class ExcludePlugin implements TransformerPlugin {
}
@Override
- public void visit(Pool in, Pool out) {
- in.visit((resource) -> {
- if (resource.getType().equals(Pool.ModuleDataType.CLASS_OR_RESOURCE)) {
+ public void visit(ModulePool in, ModulePool out) {
+ in.transformAndCopy((resource) -> {
+ if (resource.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) {
resource = predicate.test(resource.getPath()) ? resource : null;
}
return resource;
@@ -75,9 +76,9 @@ public final class ExcludePlugin implements TransformerPlugin {
}
@Override
- public Set getType() {
- Set set = new HashSet<>();
- set.add(CATEGORY.FILTER);
+ public Set getType() {
+ Set set = new HashSet<>();
+ set.add(Category.FILTER);
return Collections.unmodifiableSet(set);
}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java
index 4d502904c37..753d63e5cfc 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java
@@ -40,9 +40,10 @@ import java.util.TreeSet;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import jdk.tools.jlink.plugin.TransformerPlugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.internal.Utils;
+import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.PluginException;
/**
@@ -102,24 +103,24 @@ public final class ExcludeVMPlugin implements TransformerPlugin {
* e.g.: /java.base/native/amd64/server/libjvm.so
* /java.base/native/server/libjvm.dylib
*/
- private List getVMs(Pool in) {
+ private List getVMs(ModulePool in) {
String jvmlib = jvmlib();
- List ret = in.getModule("java.base").getContent().stream().filter((t) -> {
+ List ret = in.findModule("java.base").get().entries().filter((t) -> {
return t.getPath().endsWith("/" + jvmlib);
}).collect(Collectors.toList());
return ret;
}
@Override
- public void visit(Pool in, Pool out) {
+ public void visit(ModulePool in, ModulePool out) {
String jvmlib = jvmlib();
TreeSet existing = new TreeSet<>(new JvmComparator());
TreeSet removed = new TreeSet<>(new JvmComparator());
if (!keepAll) {
// First retrieve all available VM names and removed VM
- List jvms = getVMs(in);
+ List jvms = getVMs(in);
for (Jvm jvm : Jvm.values()) {
- for (Pool.ModuleData md : jvms) {
+ for (ModuleEntry md : jvms) {
if (md.getPath().endsWith("/" + jvm.getName() + "/" + jvmlib)) {
existing.add(jvm);
if (isRemoved(md)) {
@@ -137,9 +138,9 @@ public final class ExcludeVMPlugin implements TransformerPlugin {
}
// Rewrite the jvm.cfg file.
- in.visit((file) -> {
+ in.transformAndCopy((file) -> {
if (!keepAll) {
- if (file.getType().equals(ModuleDataType.NATIVE_LIB)) {
+ if (file.getType().equals(ModuleEntry.Type.NATIVE_LIB)) {
if (file.getPath().endsWith(JVM_CFG)) {
try {
file = handleJvmCfgFile(file, existing, removed);
@@ -155,14 +156,14 @@ public final class ExcludeVMPlugin implements TransformerPlugin {
}
- private boolean isRemoved(Pool.ModuleData file) {
+ private boolean isRemoved(ModuleEntry file) {
return !predicate.test(file.getPath());
}
@Override
- public Set getType() {
- Set set = new HashSet<>();
- set.add(CATEGORY.FILTER);
+ public Set getType() {
+ Set set = new HashSet<>();
+ set.add(Category.FILTER);
return Collections.unmodifiableSet(set);
}
@@ -217,7 +218,7 @@ public final class ExcludeVMPlugin implements TransformerPlugin {
}
}
- private Pool.ModuleData handleJvmCfgFile(Pool.ModuleData orig,
+ private ModuleEntry handleJvmCfgFile(ModuleEntry orig,
TreeSet existing,
TreeSet removed) throws IOException {
if (keepAll) {
@@ -253,7 +254,7 @@ public final class ExcludeVMPlugin implements TransformerPlugin {
byte[] content = builder.toString().getBytes(StandardCharsets.UTF_8);
- return Pool.newImageFile(orig.getModule(),
+ return ModuleEntry.create(orig.getModule(),
orig.getPath(),
orig.getType(),
new ByteArrayInputStream(content), content.length);
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java
index 7a51d6cbcdf..497d97e50a6 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java
@@ -41,10 +41,10 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
+import jdk.tools.jlink.internal.ModuleEntryImpl;
import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.internal.Utils;
@@ -68,12 +68,12 @@ public class FileCopierPlugin implements TransformerPlugin {
/**
* Symbolic link to another path.
*/
- public static abstract class SymImageFile extends Pool.ModuleData {
+ public static abstract class SymImageFile extends ModuleEntryImpl {
private final String targetPath;
public SymImageFile(String targetPath, String module, String path,
- Pool.ModuleDataType type, InputStream stream, long size) {
+ ModuleEntry.Type type, InputStream stream, long size) {
super(module, path, type, stream, size);
this.targetPath = targetPath;
}
@@ -86,7 +86,7 @@ public class FileCopierPlugin implements TransformerPlugin {
private static final class SymImageFileImpl extends SymImageFile {
public SymImageFileImpl(String targetPath, Path file, String module,
- String path, ModuleDataType type) {
+ String path, ModuleEntry.Type type) {
super(targetPath, module, path, type, newStream(file), length(file));
}
}
@@ -110,11 +110,11 @@ public class FileCopierPlugin implements TransformerPlugin {
private static final class DirectoryCopy implements FileVisitor {
private final Path source;
- private final Pool pool;
+ private final ModulePool pool;
private final String targetDir;
private final List symlinks = new ArrayList<>();
- DirectoryCopy(Path source, Pool pool, String targetDir) {
+ DirectoryCopy(Path source, ModulePool pool, String targetDir) {
this.source = source;
this.pool = pool;
this.targetDir = targetDir;
@@ -148,7 +148,7 @@ public class FileCopierPlugin implements TransformerPlugin {
}
SymImageFileImpl impl = new SymImageFileImpl(symTarget.toString(),
file, path, Objects.requireNonNull(file.getFileName()).toString(),
- Pool.ModuleDataType.OTHER);
+ ModuleEntry.Type.OTHER);
symlinks.add(impl);
} else {
addFile(pool, file, path);
@@ -172,14 +172,14 @@ public class FileCopierPlugin implements TransformerPlugin {
}
}
- private static void addFile(Pool pool, Path file, String path)
+ private static void addFile(ModulePool pool, Path file, String path)
throws IOException {
Objects.requireNonNull(pool);
Objects.requireNonNull(file);
Objects.requireNonNull(path);
- ModuleData impl = Pool.newImageFile(FAKE_MODULE,
+ ModuleEntry impl = ModuleEntry.create(FAKE_MODULE,
"/" + FAKE_MODULE + "/other/" + path,
- Pool.ModuleDataType.OTHER, newStream(file), length(file));
+ ModuleEntry.Type.OTHER, newStream(file), length(file));
try {
pool.add(impl);
} catch (Exception ex) {
@@ -188,9 +188,9 @@ public class FileCopierPlugin implements TransformerPlugin {
}
@Override
- public Set getType() {
- Set set = new HashSet<>();
- set.add(CATEGORY.TRANSFORMER);
+ public Set getType() {
+ Set set = new HashSet<>();
+ set.add(Category.TRANSFORMER);
return Collections.unmodifiableSet(set);
}
@@ -239,8 +239,8 @@ public class FileCopierPlugin implements TransformerPlugin {
}
@Override
- public void visit(Pool in, Pool out) {
- in.visit((file) -> {
+ public void visit(ModulePool in, ModulePool out) {
+ in.transformAndCopy((file) -> {
return file;
}, out);
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java
index d2b2995bdda..9e0805ec361 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java
@@ -33,8 +33,9 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
+import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
/**
@@ -60,8 +61,8 @@ public final class GenerateJLIClassesPlugin implements TransformerPlugin {
}
@Override
- public Set getType() {
- return Collections.singleton(CATEGORY.TRANSFORMER);
+ public Set getType() {
+ return Collections.singleton(Category.TRANSFORMER);
}
@Override
@@ -75,8 +76,8 @@ public final class GenerateJLIClassesPlugin implements TransformerPlugin {
}
@Override
- public Set getState() {
- return EnumSet.of(STATE.AUTO_ENABLED, STATE.FUNCTIONAL);
+ public Set getState() {
+ return EnumSet.of(State.AUTO_ENABLED, State.FUNCTIONAL);
}
@Override
@@ -151,8 +152,8 @@ public final class GenerateJLIClassesPlugin implements TransformerPlugin {
}
@Override
- public void visit(Pool in, Pool out) {
- for (Pool.ModuleData data : in.getContent()) {
+ public void visit(ModulePool in, ModulePool out) {
+ in.entries().forEach(data -> {
if (("/java.base/" + BMH + ".class").equals(data.getPath())) {
// Add BoundMethodHandle unchanged
out.add(data);
@@ -162,11 +163,11 @@ public final class GenerateJLIClassesPlugin implements TransformerPlugin {
out.add(data);
}
}
- }
+ });
}
@SuppressWarnings("unchecked")
- private void generateConcreteClass(String types, Pool.ModuleData data, Pool out) {
+ private void generateConcreteClass(String types, ModuleEntry data, ModulePool out) {
try {
// Generate class
Map.Entry result = (Map.Entry)
@@ -175,9 +176,9 @@ public final class GenerateJLIClassesPlugin implements TransformerPlugin {
byte[] bytes = result.getValue();
// Add class to pool
- Pool.ModuleData ndata = new Pool.ModuleData(data.getModule(),
+ ModuleEntry ndata = ModuleEntry.create(data.getModule(),
"/java.base/" + className + ".class",
- Pool.ModuleDataType.CLASS_OR_RESOURCE,
+ ModuleEntry.Type.CLASS_OR_RESOURCE,
new ByteArrayInputStream(bytes), bytes.length);
if (!out.contains(ndata)) {
out.add(ndata);
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java
index b8b7aa46cc1..3083c19d2ba 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java
@@ -34,6 +34,7 @@ import java.util.IllformedLocaleException;
import java.util.Locale;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
import java.util.function.Predicate;
import java.util.regex.Pattern;
@@ -44,9 +45,10 @@ import jdk.internal.org.objectweb.asm.ClassReader;
import jdk.tools.jlink.internal.ResourcePrevisitor;
import jdk.tools.jlink.internal.StringTable;
import jdk.tools.jlink.internal.Utils;
+import jdk.tools.jlink.plugin.LinkModule;
+import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
/**
@@ -112,19 +114,19 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr
}
@Override
- public void visit(Pool in, Pool out) {
- in.visit((resource) -> {
+ public void visit(ModulePool in, ModulePool out) {
+ in.transformAndCopy((resource) -> {
if (resource.getModule().equals(MODULENAME)) {
String path = resource.getPath();
resource = predicate.test(path) ? resource: null;
if (resource != null &&
- resource.getType().equals(ModuleDataType.CLASS_OR_RESOURCE)) {
+ resource.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) {
byte[] bytes = resource.getBytes();
ClassReader cr = new ClassReader(bytes);
if (Arrays.stream(cr.getInterfaces())
.anyMatch(i -> i.contains(METAINFONAME)) &&
stripUnsupportedLocales(bytes, cr)) {
- resource = new Pool.ModuleData(MODULENAME, path,
+ resource = ModuleEntry.create(MODULENAME, path,
resource.getType(),
new ByteArrayInputStream(bytes), bytes.length);
}
@@ -135,9 +137,9 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr
}
@Override
- public Set getType() {
- Set set = new HashSet<>();
- set.add(CATEGORY.FILTER);
+ public Set getType() {
+ Set set = new HashSet<>();
+ set.add(Category.FILTER);
return Collections.unmodifiableSet(set);
}
@@ -172,12 +174,13 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr
}
@Override
- public void previsit(Pool resources, StringTable strings) {
+ public void previsit(ModulePool resources, StringTable strings) {
final Pattern p = Pattern.compile(".*((Data_)|(Names_))(?.*)\\.class");
- Pool.Module module = resources.getModule(MODULENAME);
+ Optional optMod = resources.findModule(MODULENAME);
// jdk.localedata module validation
- if (module != null) {
+ if (optMod.isPresent()) {
+ LinkModule module = optMod.get();
Set packages = module.getAllPackages();
if (!packages.containsAll(LOCALEDATA_PACKAGES)) {
throw new PluginException(PluginsResourceBundle.getMessage(NAME + ".missingpackages") +
@@ -186,7 +189,7 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr
.collect(Collectors.joining(",\n\t")));
}
- available = Stream.concat(module.getContent().stream()
+ available = Stream.concat(module.entries()
.map(md -> p.matcher(md.getPath()))
.filter(m -> m.matches())
.map(m -> m.group("tag").replaceAll("_", "-")),
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java
index 4f8e5eade53..9632cdf9b95 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java
@@ -24,7 +24,6 @@
*/
package jdk.tools.jlink.internal.plugins;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
@@ -287,9 +286,9 @@ public final class OptimizationPlugin extends AsmPlugin {
}
@Override
- public Set getType() {
- Set set = new HashSet<>();
- set.add(CATEGORY.TRANSFORMER);
+ public Set getType() {
+ Set set = new HashSet<>();
+ set.add(Category.TRANSFORMER);
return Collections.unmodifiableSet(set);
}
}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java
index 8fb124dd775..5060bf5c519 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java
@@ -36,9 +36,8 @@ import java.util.Map;
import java.util.Set;
import java.util.function.ToIntFunction;
import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.internal.Utils;
@@ -62,15 +61,15 @@ public final class OrderResourcesPlugin implements TransformerPlugin {
}
static class SortWrapper {
- private final ModuleData resource;
+ private final ModuleEntry resource;
private final int ordinal;
- SortWrapper(ModuleData resource, int ordinal) {
+ SortWrapper(ModuleEntry resource, int ordinal) {
this.resource = resource;
this.ordinal = ordinal;
}
- ModuleData getResource() {
+ ModuleEntry getResource() {
return resource;
}
@@ -95,7 +94,7 @@ public final class OrderResourcesPlugin implements TransformerPlugin {
return path;
}
- private int getOrdinal(ModuleData resource) {
+ private int getOrdinal(ModuleEntry resource) {
String path = resource.getPath();
Integer value = orderedPaths.get(stripModule(path));
@@ -126,23 +125,23 @@ public final class OrderResourcesPlugin implements TransformerPlugin {
}
@Override
- public void visit(Pool in, Pool out) {
- in.getContent().stream()
+ public void visit(ModulePool in, ModulePool out) {
+ in.entries()
.filter(resource -> resource.getType()
- .equals(ModuleDataType.CLASS_OR_RESOURCE))
+ .equals(ModuleEntry.Type.CLASS_OR_RESOURCE))
.map((resource) -> new SortWrapper(resource, getOrdinal(resource)))
.sorted(OrderResourcesPlugin::compare)
.forEach((wrapper) -> out.add(wrapper.getResource()));
- in.getContent().stream()
+ in.entries()
.filter(other -> !other.getType()
- .equals(ModuleDataType.CLASS_OR_RESOURCE))
+ .equals(ModuleEntry.Type.CLASS_OR_RESOURCE))
.forEach((other) -> out.add(other));
}
@Override
- public Set getType() {
- Set set = new HashSet<>();
- set.add(CATEGORY.SORTER);
+ public Set getType() {
+ Set set = new HashSet<>();
+ set.add(Category.SORTER);
return Collections.unmodifiableSet(set);
}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java
index bbc7428a41e..579aace7e0a 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java
@@ -24,34 +24,33 @@
*/
package jdk.tools.jlink.internal.plugins;
-import java.lang.module.ModuleDescriptor;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Collections;
import java.util.EnumSet;
-import java.util.List;
+import java.util.HashMap;
import java.util.Map;
-import java.util.Set;
import java.util.Properties;
-
+import java.util.Set;
+import java.util.function.Function;
import jdk.tools.jlink.internal.Utils;
-import jdk.tools.jlink.plugin.ExecutableImage;
-import jdk.tools.jlink.plugin.PluginContext;
-import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.PostProcessorPlugin;
+import jdk.tools.jlink.plugin.ModulePool;
+import jdk.tools.jlink.plugin.Plugin.Category;
+import jdk.tools.jlink.plugin.Plugin.State;
+import jdk.tools.jlink.plugin.TransformerPlugin;
/**
* This plugin adds/deletes information for 'release' file.
*/
-public final class ReleaseInfoPlugin implements PostProcessorPlugin {
+public final class ReleaseInfoPlugin implements TransformerPlugin {
// option name
public static final String NAME = "release-info";
public static final String KEYS = "keys";
+ private final Map release = new HashMap<>();
@Override
- public Set getType() {
- return Collections.singleton(CATEGORY.PROCESSOR);
+ public Set getType() {
+ return Collections.singleton(Category.METAINFO_ADDER);
}
@Override
@@ -65,8 +64,8 @@ public final class ReleaseInfoPlugin implements PostProcessorPlugin {
}
@Override
- public Set getState() {
- return EnumSet.of(STATE.FUNCTIONAL);
+ public Set getState() {
+ return EnumSet.of(State.FUNCTIONAL);
}
@Override
@@ -80,49 +79,49 @@ public final class ReleaseInfoPlugin implements PostProcessorPlugin {
}
@Override
- public void configure(Map config, PluginContext ctx) {
- Properties release = ctx != null? ctx.getReleaseProperties() : null;
- if (release != null) {
- String operation = config.get(NAME);
- switch (operation) {
- case "add": {
- // leave it to open-ended! source, java_version, java_full_version
- // can be passed via this option like:
- //
- // --release-info add:build_type=fastdebug,source=openjdk,java_version=9
- // and put whatever value that was passed in command line.
+ public void configure(Map config) {
+ String operation = config.get(NAME);
+ switch (operation) {
+ case "add": {
+ // leave it to open-ended! source, java_version, java_full_version
+ // can be passed via this option like:
+ //
+ // --release-info add:build_type=fastdebug,source=openjdk,java_version=9
+ // and put whatever value that was passed in command line.
- config.keySet().stream().
- filter(s -> !NAME.equals(s)).
- forEach(s -> release.put(s, config.get(s)));
- }
- break;
-
- case "del": {
- // --release-info del:keys=openjdk,java_version
- String[] keys = Utils.listParser.apply(config.get(KEYS));
- for (String k : keys) {
- release.remove(k);
- }
- }
- break;
-
- default: {
- // --release-info
- try (FileInputStream fis = new FileInputStream(operation)) {
- release.load(fis);
- } catch (IOException exp) {
- throw new RuntimeException(exp);
- }
- }
- break;
+ config.keySet().stream().
+ filter(s -> !NAME.equals(s)).
+ forEach(s -> release.put(s, config.get(s)));
}
+ break;
+
+ case "del": {
+ // --release-info del:keys=openjdk,java_version
+ String[] keys = Utils.listParser.apply(config.get(KEYS));
+ for (String k : keys) {
+ release.remove(k);
+ }
+ }
+ break;
+
+ default: {
+ // --release-info
+ Properties props = new Properties();
+ try (FileInputStream fis = new FileInputStream(operation)) {
+ props.load(fis);
+ } catch (IOException exp) {
+ throw new RuntimeException(exp);
+ }
+ props.forEach((k, v) -> release.put(k.toString(), v.toString()));
+ }
+ break;
}
}
@Override
- public List process(ExecutableImage image) {
- // Nothing to do! Release info copied already during configure!
- return Collections.emptyList();
+ public void visit(ModulePool in, ModulePool out) {
+ in.transformAndCopy(Function.identity(), out);
+ out.getReleaseProperties().putAll(in.getReleaseProperties());
+ out.getReleaseProperties().putAll(release);
}
}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java
index a4aa8f9d5ca..b3a1e7cf3cf 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java
@@ -56,11 +56,11 @@ import java.util.stream.Collectors;
import jdk.internal.jimage.decompressor.CompressIndexes;
import jdk.internal.jimage.decompressor.SignatureParser;
import jdk.internal.jimage.decompressor.StringSharingDecompressor;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.internal.ResourcePrevisitor;
import jdk.tools.jlink.internal.StringTable;
import jdk.tools.jlink.internal.Utils;
@@ -228,7 +228,7 @@ public class StringSharingPlugin implements TransformerPlugin, ResourcePrevisito
}
}
- public byte[] transform(ModuleData resource, Pool out,
+ public byte[] transform(ModuleEntry resource, ModulePool out,
StringTable strings) throws IOException, Exception {
byte[] content = resource.getBytes();
ClassFile cf;
@@ -243,7 +243,7 @@ public class StringSharingPlugin implements TransformerPlugin, ResourcePrevisito
}
@SuppressWarnings("fallthrough")
- private byte[] optimize(ModuleData resource, Pool resources,
+ private byte[] optimize(ModuleEntry resource, ModulePool resources,
StringTable strings,
Set descriptorIndexes, byte[] content) throws Exception {
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(content));
@@ -348,27 +348,27 @@ public class StringSharingPlugin implements TransformerPlugin, ResourcePrevisito
}
@Override
- public Set getType() {
- Set set = new HashSet<>();
- set.add(CATEGORY.COMPRESSOR);
+ public Set getType() {
+ Set set = new HashSet<>();
+ set.add(Category.COMPRESSOR);
return Collections.unmodifiableSet(set);
}
@Override
- public void visit(Pool in, Pool result) {
+ public void visit(ModulePool in, ModulePool result) {
CompactCPHelper visit = new CompactCPHelper();
- in.visit((resource) -> {
- ModuleData res = resource;
+ in.transformAndCopy((resource) -> {
+ ModuleEntry res = resource;
if (predicate.test(resource.getPath()) && resource.getPath().endsWith(".class")) {
byte[] compressed = null;
try {
- compressed = visit.transform(resource, result, ((PoolImpl) in).getStringTable());
+ compressed = visit.transform(resource, result, ((ModulePoolImpl) in).getStringTable());
} catch (Exception ex) {
throw new PluginException(ex);
}
- res = PoolImpl.newCompressedResource(resource,
+ res = ModulePoolImpl.newCompressedResource(resource,
ByteBuffer.wrap(compressed), getName(), null,
- ((PoolImpl) in).getStringTable(), in.getByteOrder());
+ ((ModulePoolImpl) in).getStringTable(), in.getByteOrder());
}
return res;
}, result);
@@ -405,10 +405,10 @@ public class StringSharingPlugin implements TransformerPlugin, ResourcePrevisito
}
@Override
- public void previsit(Pool resources, StringTable strings) {
+ public void previsit(ModulePool resources, StringTable strings) {
CompactCPHelper preVisit = new CompactCPHelper();
- for (ModuleData resource : resources.getContent()) {
- if (resource.getType().equals(Pool.ModuleDataType.CLASS_OR_RESOURCE)
+ resources.entries().forEach(resource -> {
+ if (resource.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)
&& resource.getPath().endsWith(".class") && predicate.test(resource.getPath())) {
try {
preVisit.transform(resource, null, strings);
@@ -416,6 +416,6 @@ public class StringSharingPlugin implements TransformerPlugin, ResourcePrevisito
throw new PluginException(ex);
}
}
- }
+ });
}
}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java
index ae927952226..4e7a036d838 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java
@@ -29,14 +29,12 @@ import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.Collections;
import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;
import jdk.internal.org.objectweb.asm.ClassReader;
import jdk.internal.org.objectweb.asm.ClassWriter;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
/**
@@ -61,9 +59,9 @@ public final class StripDebugPlugin implements TransformerPlugin {
}
@Override
- public Set getType() {
- Set set = new HashSet<>();
- set.add(CATEGORY.TRANSFORMER);
+ public Set getType() {
+ Set set = new HashSet<>();
+ set.add(Category.TRANSFORMER);
return Collections.unmodifiableSet(set);
}
@@ -73,11 +71,11 @@ public final class StripDebugPlugin implements TransformerPlugin {
}
@Override
- public void visit(Pool in, Pool out) {
+ public void visit(ModulePool in, ModulePool out) {
//remove *.diz files as well as debug attributes.
- in.visit((resource) -> {
- ModuleData res = resource;
- if (resource.getType().equals(ModuleDataType.CLASS_OR_RESOURCE)) {
+ in.transformAndCopy((resource) -> {
+ ModuleEntry res = resource;
+ if (resource.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) {
String path = resource.getPath();
if (path.endsWith(".class")) {
if (path.endsWith("module-info.class")) {
@@ -87,7 +85,7 @@ public final class StripDebugPlugin implements TransformerPlugin {
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
reader.accept(writer, ClassReader.SKIP_DEBUG);
byte[] content = writer.toByteArray();
- res = Pool.newResource(path, new ByteArrayInputStream(content), content.length);
+ res = ModuleEntry.create(path, new ByteArrayInputStream(content), content.length);
}
}
} else if (predicate.test(res.getPath())) {
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java
index dc64582be21..496a4e538d7 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java
@@ -26,9 +26,9 @@ package jdk.tools.jlink.internal.plugins;
import java.util.Collections;
import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
/**
@@ -45,16 +45,16 @@ public final class StripNativeCommandsPlugin implements TransformerPlugin {
}
@Override
- public Set getType() {
- Set set = new HashSet<>();
- set.add(CATEGORY.FILTER);
+ public Set getType() {
+ Set set = new HashSet<>();
+ set.add(Category.FILTER);
return Collections.unmodifiableSet(set);
}
@Override
- public void visit(Pool in, Pool out) {
- in.visit((file) -> {
- return file.getType() == Pool.ModuleDataType.NATIVE_CMD ? null : file;
+ public void visit(ModulePool in, ModulePool out) {
+ in.transformAndCopy((file) -> {
+ return file.getType() == ModuleEntry.Type.NATIVE_CMD ? null : file;
}, out);
}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModuleDescriptorPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModuleDescriptorPlugin.java
index f4cba7607ea..b60fecb5d16 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModuleDescriptorPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModuleDescriptorPlugin.java
@@ -36,6 +36,7 @@ import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
@@ -50,9 +51,10 @@ import jdk.internal.org.objectweb.asm.Opcodes;
import static jdk.internal.org.objectweb.asm.Opcodes.*;
import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.internal.plugins.SystemModuleDescriptorPlugin.Builder.*;
+import jdk.tools.jlink.plugin.ModuleEntry;
/**
* Jlink plugin to reconstitute module descriptors for installed modules.
@@ -81,8 +83,8 @@ public final class SystemModuleDescriptorPlugin implements TransformerPlugin {
}
@Override
- public Set getType() {
- return Collections.singleton(CATEGORY.TRANSFORMER);
+ public Set getType() {
+ return Collections.singleton(Category.TRANSFORMER);
}
@Override
@@ -96,9 +98,9 @@ public final class SystemModuleDescriptorPlugin implements TransformerPlugin {
}
@Override
- public Set getState() {
- return enabled ? EnumSet.of(STATE.AUTO_ENABLED, STATE.FUNCTIONAL)
- : EnumSet.of(STATE.DISABLED);
+ public Set getState() {
+ return enabled ? EnumSet.of(State.AUTO_ENABLED, State.FUNCTIONAL)
+ : EnumSet.of(State.DISABLED);
}
@Override
@@ -110,7 +112,7 @@ public final class SystemModuleDescriptorPlugin implements TransformerPlugin {
@Override
- public void visit(Pool in, Pool out) {
+ public void visit(ModulePool in, ModulePool out) {
if (!enabled) {
throw new PluginException(NAME + " was set");
}
@@ -119,13 +121,14 @@ public final class SystemModuleDescriptorPlugin implements TransformerPlugin {
// generate the byte code to create ModuleDescriptors
// skip parsing module-info.class and skip name check
- for (Pool.Module module : in.getModules()) {
- Pool.ModuleData data = module.get("module-info.class");
- if (data == null) {
+ in.modules().forEach(module -> {
+ Optional optData = module.findEntry("module-info.class");
+ if (! optData.isPresent()) {
// automatic module not supported yet
throw new PluginException("module-info.class not found for " +
module.getName() + " module");
}
+ ModuleEntry data = optData.get();
assert module.getName().equals(data.getModule());
try {
ByteArrayInputStream bain = new ByteArrayInputStream(data.getBytes());
@@ -141,7 +144,7 @@ public final class SystemModuleDescriptorPlugin implements TransformerPlugin {
ModuleInfoRewriter minfoWriter =
new ModuleInfoRewriter(bain, mbuilder.conceals());
// replace with the overridden version
- data = new Pool.ModuleData(data.getModule(),
+ data = ModuleEntry.create(data.getModule(),
data.getPath(),
data.getType(),
minfoWriter.stream(),
@@ -151,19 +154,17 @@ public final class SystemModuleDescriptorPlugin implements TransformerPlugin {
} catch (IOException e) {
throw new PluginException(e);
}
-
- }
+ });
// Generate the new class
ClassWriter cwriter = builder.build();
- for (Pool.ModuleData data : in.getContent()) {
+ in.entries().forEach(data -> {
if (data.getPath().endsWith("module-info.class"))
- continue;
-
+ return;
if (builder.isOverriddenClass(data.getPath())) {
byte[] bytes = cwriter.toByteArray();
- Pool.ModuleData ndata =
- new Pool.ModuleData(data.getModule(),
+ ModuleEntry ndata =
+ ModuleEntry.create(data.getModule(),
data.getPath(),
data.getType(),
new ByteArrayInputStream(bytes),
@@ -172,7 +173,7 @@ public final class SystemModuleDescriptorPlugin implements TransformerPlugin {
} else {
out.add(data);
}
- }
+ });
}
/*
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java
index df66e300f5c..d3dd7bff210 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java
@@ -34,10 +34,9 @@ import java.util.Set;
import java.util.function.Predicate;
import java.util.zip.Deflater;
import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.internal.PoolImpl;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.internal.ModulePoolImpl;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.internal.Utils;
@@ -68,9 +67,9 @@ public final class ZipPlugin implements TransformerPlugin {
}
@Override
- public Set getType() {
- Set set = new HashSet<>();
- set.add(CATEGORY.COMPRESSOR);
+ public Set getType() {
+ Set set = new HashSet<>();
+ set.add(Category.COMPRESSOR);
return Collections.unmodifiableSet(set);
}
@@ -124,16 +123,16 @@ public final class ZipPlugin implements TransformerPlugin {
}
@Override
- public void visit(Pool in, Pool out) {
- in.visit((resource) -> {
- ModuleData res = resource;
- if (resource.getType().equals(ModuleDataType.CLASS_OR_RESOURCE)
+ public void visit(ModulePool in, ModulePool out) {
+ in.transformAndCopy((resource) -> {
+ ModuleEntry res = resource;
+ if (resource.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)
&& predicate.test(resource.getPath())) {
byte[] compressed;
compressed = compress(resource.getBytes());
- res = PoolImpl.newCompressedResource(resource,
+ res = ModulePoolImpl.newCompressedResource(resource,
ByteBuffer.wrap(compressed), getName(), null,
- ((PoolImpl) in).getStringTable(), in.getByteOrder());
+ ((ModulePoolImpl) in).getStringTable(), in.getByteOrder());
}
return res;
}, out);
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPlugin.java
index 9902959d059..52712172d5e 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPlugin.java
@@ -26,9 +26,9 @@ package jdk.tools.jlink.internal.plugins.asm;
import java.util.Objects;
import jdk.tools.jlink.plugin.TransformerPlugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
+import jdk.tools.jlink.internal.ModulePoolImpl;
/**
* Extend this class to develop your own plugin in order to transform jimage
@@ -41,17 +41,17 @@ public abstract class AsmPlugin implements TransformerPlugin {
}
@Override
- public void visit(Pool allContent, Pool outResources) {
+ public void visit(ModulePool allContent, ModulePool outResources) {
Objects.requireNonNull(allContent);
Objects.requireNonNull(outResources);
- PoolImpl resources = new PoolImpl(allContent.getByteOrder());
- for(ModuleData md : allContent.getContent()) {
- if(md.getType().equals(Pool.ModuleDataType.CLASS_OR_RESOURCE)) {
+ ModulePoolImpl resources = new ModulePoolImpl(allContent.getByteOrder());
+ allContent.entries().forEach(md -> {
+ if(md.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) {
resources.add(md);
} else {
outResources.add(md);
}
- }
+ });
AsmPools pools = new AsmPools(resources);
visit(pools);
pools.fillOutputResources(outResources);
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPool.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPool.java
index 9184bb86257..aa5c1cb5ef5 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPool.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPool.java
@@ -24,13 +24,12 @@
*/
package jdk.tools.jlink.internal.plugins.asm;
-import java.io.InputStream;
-import java.nio.ByteBuffer;
import java.util.Collection;
import java.util.List;
import jdk.internal.org.objectweb.asm.ClassReader;
import jdk.internal.org.objectweb.asm.ClassWriter;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
/**
* A pool of ClassReader and other resource files.
@@ -138,14 +137,14 @@ public interface AsmPool {
* @return The ClassReader or null if the class is not found.
* @throws jdk.tools.jlink.plugin.PluginException
*/
- public ClassReader getClassReader(Pool.ModuleData res);
+ public ClassReader getClassReader(ModuleEntry res);
/**
* Returns all the classes contained in the writable pool.
*
* @return The collection of classes.
*/
- public Collection getClasses();
+ public Collection getClasses();
}
/**
@@ -185,14 +184,14 @@ public interface AsmPool {
* @param res The java resource
* @return The Resource or null if the resource is not found.
*/
- public ResourceFile getResourceFile(Pool.ModuleData res);
+ public ResourceFile getResourceFile(ModuleEntry res);
/**
* Returns all the resources contained in the writable pool.
*
* @return The array of resources.
*/
- public Collection getResourceFiles();
+ public Collection getResourceFiles();
}
/**
@@ -206,7 +205,7 @@ public interface AsmPool {
* @return The resource paths ordered in the way to use for storage in the jimage.
* @throws jdk.tools.jlink.plugin.PluginException
*/
- public List sort(Pool resources);
+ public List sort(ModulePool resources);
}
/**
@@ -237,7 +236,7 @@ public interface AsmPool {
*
* @return The classes.
*/
- public Collection getClasses();
+ public Collection getClasses();
/**
* Returns the resources contained in the pool. Resources are all the file
@@ -245,7 +244,7 @@ public interface AsmPool {
*
* @return The array of resource files.
*/
- public Collection getResourceFiles();
+ public Collection getResourceFiles();
/**
* Retrieves a resource based on the binary name. This name doesn't contain
@@ -266,7 +265,7 @@ public interface AsmPool {
* @param res The resource
* @return The resource file or null if it doesn't exist.
*/
- public ResourceFile getResourceFile(Pool.ModuleData res);
+ public ResourceFile getResourceFile(ModuleEntry res);
/**
* Retrieve a ClassReader from the pool.
@@ -284,7 +283,7 @@ public interface AsmPool {
* @return A reader or null if the class is unknown
* @throws jdk.tools.jlink.plugin.PluginException
*/
- public ClassReader getClassReader(Pool.ModuleData res);
+ public ClassReader getClassReader(ModuleEntry res);
/**
* To visit the set of ClassReaders.
@@ -310,6 +309,6 @@ public interface AsmPool {
* @param output The pool used to fill the jimage.
* @throws jdk.tools.jlink.plugin.PluginException
*/
- public void fillOutputResources(Pool output);
+ public void fillOutputResources(ModulePool output);
}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPoolImpl.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPoolImpl.java
index cb838d11efa..20c17c85b7b 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPoolImpl.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPoolImpl.java
@@ -41,15 +41,14 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
-import java.util.Optional;
import java.util.Set;
import jdk.internal.org.objectweb.asm.ClassReader;
import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.tools.jlink.internal.ImageFileCreator;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
+import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModulePool;
/**
* A pool of ClassReader and other resource files. This class allows to
@@ -94,7 +93,7 @@ final class AsmPoolImpl implements AsmModulePool {
}
byte[] content = writer.toByteArray();
- ModuleData res = Pool.newResource(path,
+ ModuleEntry res = ModuleEntry.create(path,
new ByteArrayInputStream(content), content.length);
transformedClasses.put(className, res);
}
@@ -108,7 +107,7 @@ final class AsmPoolImpl implements AsmModulePool {
public void forgetClass(String className) {
Objects.requireNonNull(className);
// do we have a resource?
- ModuleData res = transformedClasses.get(className);
+ ModuleEntry res = transformedClasses.get(className);
if (res == null) {
res = inputClasses.get(className);
if (res == null) {
@@ -130,7 +129,7 @@ final class AsmPoolImpl implements AsmModulePool {
@Override
public ClassReader getClassReader(String binaryName) {
Objects.requireNonNull(binaryName);
- ModuleData res = transformedClasses.get(binaryName);
+ ModuleEntry res = transformedClasses.get(binaryName);
ClassReader reader = null;
if (res != null) {
reader = getClassReader(res);
@@ -144,16 +143,16 @@ final class AsmPoolImpl implements AsmModulePool {
* @return The array of transformed classes.
*/
@Override
- public Collection getClasses() {
- List classes = new ArrayList<>();
- for (Entry entry : transformedClasses.entrySet()) {
+ public Collection getClasses() {
+ List classes = new ArrayList<>();
+ for (Entry entry : transformedClasses.entrySet()) {
classes.add(entry.getValue());
}
return classes;
}
@Override
- public ClassReader getClassReader(ModuleData res) {
+ public ClassReader getClassReader(ModuleEntry res) {
return newClassReader(res.getBytes());
}
}
@@ -176,7 +175,7 @@ final class AsmPoolImpl implements AsmModulePool {
public void addResourceFile(ResourceFile resFile) {
Objects.requireNonNull(resFile);
String path = toResourceNamePath(resFile.getPath());
- ModuleData res = Pool.newResource(path, resFile.getContent());
+ ModuleEntry res = ModuleEntry.create(path, resFile.getContent());
transformedResources.put(resFile.getPath(), res);
}
@@ -191,7 +190,7 @@ final class AsmPoolImpl implements AsmModulePool {
Objects.requireNonNull(resourceName);
String path = toResourceNamePath(resourceName);
// do we have a resource?
- ModuleData res = transformedResources.get(resourceName);
+ ModuleEntry res = transformedResources.get(resourceName);
if (res == null) {
res = inputResources.get(resourceName);
if (res == null) {
@@ -212,7 +211,7 @@ final class AsmPoolImpl implements AsmModulePool {
@Override
public ResourceFile getResourceFile(String name) {
Objects.requireNonNull(name);
- ModuleData res = transformedResources.get(name);
+ ModuleEntry res = transformedResources.get(name);
ResourceFile resFile = null;
if (res != null) {
resFile = getResourceFile(res);
@@ -226,24 +225,24 @@ final class AsmPoolImpl implements AsmModulePool {
* @return The array of transformed classes.
*/
@Override
- public Collection getResourceFiles() {
- List resources = new ArrayList<>();
- for (Entry entry : transformedResources.entrySet()) {
+ public Collection getResourceFiles() {
+ List resources = new ArrayList<>();
+ for (Entry entry : transformedResources.entrySet()) {
resources.add(entry.getValue());
}
return resources;
}
@Override
- public ResourceFile getResourceFile(ModuleData res) {
+ public ResourceFile getResourceFile(ModuleEntry res) {
return new ResourceFile(toJavaBinaryResourceName(res.getPath()),
res.getBytes());
}
}
- private final Pool jimageResources;
- private final Map inputClasses;
- private final Map inputResources;
+ private final ModulePool jimageResources;
+ private final Map inputClasses;
+ private final Map inputResources;
private final Map inputClassPackageMapping;
private final Map inputOtherPackageMapping;
@@ -254,9 +253,9 @@ final class AsmPoolImpl implements AsmModulePool {
private Sorter sorter;
- private final Map transformedClasses
+ private final Map transformedClasses
= new LinkedHashMap<>();
- private final Map transformedResources
+ private final Map transformedResources
= new LinkedHashMap<>();
private final List forgetResources = new ArrayList<>();
private final Map newPackageMapping = new HashMap<>();
@@ -274,7 +273,7 @@ final class AsmPoolImpl implements AsmModulePool {
* @param pools The resource pools.
* @param descriptor The module descriptor.
*/
- AsmPoolImpl(Pool inputResources, String moduleName,
+ AsmPoolImpl(ModulePool inputResources, String moduleName,
AsmPools pools,
ModuleDescriptor descriptor) {
Objects.requireNonNull(inputResources);
@@ -285,11 +284,11 @@ final class AsmPoolImpl implements AsmModulePool {
this.moduleName = moduleName;
this.pools = pools;
this.descriptor = descriptor;
- Map classes = new LinkedHashMap<>();
- Map resources = new LinkedHashMap<>();
+ Map classes = new LinkedHashMap<>();
+ Map resources = new LinkedHashMap<>();
Map packageClassToModule = new HashMap<>();
Map packageOtherToModule = new HashMap<>();
- for (ModuleData res : inputResources.getContent()) {
+ inputResources.entries().forEach(res -> {
if (res.getPath().endsWith(".class")) {
classes.put(toJavaBinaryClassName(res.getPath()), res);
} else {
@@ -305,7 +304,7 @@ final class AsmPoolImpl implements AsmModulePool {
packageOtherToModule.put(split[1], res.getModule());
}
}
- }
+ });
this.inputClasses = Collections.unmodifiableMap(classes);
this.inputResources = Collections.unmodifiableMap(resources);
@@ -356,7 +355,7 @@ final class AsmPoolImpl implements AsmModulePool {
* @return The array of classes.
*/
@Override
- public Collection getClasses() {
+ public Collection getClasses() {
return inputClasses.values();
}
@@ -367,7 +366,7 @@ final class AsmPoolImpl implements AsmModulePool {
* @return The array of classes.
*/
@Override
- public Collection getResourceFiles() {
+ public Collection getResourceFiles() {
return inputResources.values();
}
@@ -385,7 +384,7 @@ final class AsmPoolImpl implements AsmModulePool {
@Override
public ResourceFile getResourceFile(String binaryName) {
Objects.requireNonNull(binaryName);
- ModuleData res = inputResources.get(binaryName);
+ ModuleEntry res = inputResources.get(binaryName);
ResourceFile resFile = null;
if (res != null) {
resFile = getResourceFile(res);
@@ -402,7 +401,7 @@ final class AsmPoolImpl implements AsmModulePool {
@Override
public ClassReader getClassReader(String binaryName) {
Objects.requireNonNull(binaryName);
- ModuleData res = inputClasses.get(binaryName);
+ ModuleEntry res = inputClasses.get(binaryName);
ClassReader reader = null;
if (res != null) {
reader = getClassReader(res);
@@ -411,13 +410,13 @@ final class AsmPoolImpl implements AsmModulePool {
}
@Override
- public ResourceFile getResourceFile(ModuleData res) {
+ public ResourceFile getResourceFile(ModuleEntry res) {
return new ResourceFile(toJavaBinaryResourceName(res.getPath()),
res.getBytes());
}
@Override
- public ClassReader getClassReader(ModuleData res) {
+ public ClassReader getClassReader(ModuleEntry res) {
return newClassReader(res.getBytes());
}
@@ -505,7 +504,7 @@ final class AsmPoolImpl implements AsmModulePool {
@Override
public void visitClassReaders(ClassReaderVisitor visitor) {
Objects.requireNonNull(visitor);
- for (ModuleData res : getClasses()) {
+ for (ModuleEntry res : getClasses()) {
ClassReader reader = newClassReader(res.getBytes());
ClassWriter writer = visitor.visit(reader);
if (writer != null) {
@@ -523,7 +522,7 @@ final class AsmPoolImpl implements AsmModulePool {
@Override
public void visitResourceFiles(ResourceFileVisitor visitor) {
Objects.requireNonNull(visitor);
- for (ModuleData resource : getResourceFiles()) {
+ for (ModuleEntry resource : getResourceFiles()) {
ResourceFile resFile
= new ResourceFile(toJavaBinaryResourceName(resource.getPath()),
resource.getBytes());
@@ -540,18 +539,18 @@ final class AsmPoolImpl implements AsmModulePool {
* been set, it is used to sort the returned resources. *
*/
@Override
- public void fillOutputResources(Pool outputResources) {
+ public void fillOutputResources(ModulePool outputResources) {
List added = new ArrayList<>();
// If the sorter is null, use the input order.
// New resources are added at the end
// First input classes that have not been removed
- Pool output = new PoolImpl(outputResources.getByteOrder(),
- ((PoolImpl)outputResources).getStringTable());
- for (ModuleData inResource : jimageResources.getContent()) {
+ ModulePool output = new ModulePoolImpl(outputResources.getByteOrder(),
+ ((ModulePoolImpl)outputResources).getStringTable());
+ jimageResources.entries().forEach(inResource -> {
if (!forgetResources.contains(inResource.getPath())) {
- ModuleData resource = inResource;
+ ModuleEntry resource = inResource;
// Do we have a transformed class with the same name?
- ModuleData res = transformedResources.
+ ModuleEntry res = transformedResources.
get(toJavaBinaryResourceName(inResource.getPath()));
if (res != null) {
resource = res;
@@ -565,10 +564,10 @@ final class AsmPoolImpl implements AsmModulePool {
output.add(resource);
added.add(resource.getPath());
}
- }
+ });
// Then new resources
- for (Map.Entry entry : transformedResources.entrySet()) {
- ModuleData resource = entry.getValue();
+ for (Map.Entry entry : transformedResources.entrySet()) {
+ ModuleEntry resource = entry.getValue();
if (!forgetResources.contains(resource.getPath())) {
if (!added.contains(resource.getPath())) {
output.add(resource);
@@ -576,8 +575,8 @@ final class AsmPoolImpl implements AsmModulePool {
}
}
// And new classes
- for (Map.Entry entry : transformedClasses.entrySet()) {
- ModuleData resource = entry.getValue();
+ for (Map.Entry entry : transformedClasses.entrySet()) {
+ ModuleEntry resource = entry.getValue();
if (!forgetResources.contains(resource.getPath())) {
if (!added.contains(resource.getPath())) {
output.add(resource);
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPools.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPools.java
index bbb2d5403f8..53742ee5ad7 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPools.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPools.java
@@ -41,11 +41,11 @@ import java.util.Objects;
import java.util.Set;
import jdk.internal.org.objectweb.asm.ClassReader;
import jdk.internal.org.objectweb.asm.ClassWriter;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
import jdk.tools.jlink.internal.plugins.asm.AsmPool.Sorter;
+import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModulePool;
/**
* A container for pools of ClassReader and other resource files. A pool of all
@@ -97,10 +97,10 @@ public final class AsmPools {
}
@Override
- public Collection getClasses() {
- List all = new ArrayList<>();
+ public Collection getClasses() {
+ List all = new ArrayList<>();
visitAllPools((AsmModulePool pool) -> {
- for (Pool.ModuleData rf : pool.getTransformedClasses().getClasses()) {
+ for (ModuleEntry rf : pool.getTransformedClasses().getClasses()) {
all.add(rf);
}
});
@@ -108,7 +108,7 @@ public final class AsmPools {
}
@Override
- public ClassReader getClassReader(Pool.ModuleData res) {
+ public ClassReader getClassReader(ModuleEntry res) {
return visitPools((AsmModulePool pool) -> {
return pool.getTransformedClasses().getClassReader(res);
});
@@ -140,10 +140,10 @@ public final class AsmPools {
}
@Override
- public Collection getResourceFiles() {
- List all = new ArrayList<>();
+ public Collection getResourceFiles() {
+ List all = new ArrayList<>();
visitAllPools((AsmModulePool pool) -> {
- for (Pool.ModuleData rf : pool.getTransformedResourceFiles().getResourceFiles()) {
+ for (ModuleEntry rf : pool.getTransformedResourceFiles().getResourceFiles()) {
all.add(rf);
}
});
@@ -151,7 +151,7 @@ public final class AsmPools {
}
@Override
- public ResourceFile getResourceFile(Pool.ModuleData res) {
+ public ResourceFile getResourceFile(ModuleEntry res) {
return visitPools((AsmModulePool pool) -> {
return pool.getTransformedResourceFiles().getResourceFile(res);
});
@@ -175,10 +175,10 @@ public final class AsmPools {
}
@Override
- public Collection getClasses() {
- List all = new ArrayList<>();
+ public Collection getClasses() {
+ List all = new ArrayList<>();
visitAllPools((AsmModulePool pool) -> {
- for (Pool.ModuleData rf : pool.getClasses()) {
+ for (ModuleEntry rf : pool.getClasses()) {
all.add(rf);
}
});
@@ -186,10 +186,10 @@ public final class AsmPools {
}
@Override
- public Collection getResourceFiles() {
- List all = new ArrayList<>();
+ public Collection getResourceFiles() {
+ List all = new ArrayList<>();
visitAllPools((AsmModulePool pool) -> {
- for (Pool.ModuleData rf : pool.getResourceFiles()) {
+ for (ModuleEntry rf : pool.getResourceFiles()) {
all.add(rf);
}
});
@@ -211,14 +211,14 @@ public final class AsmPools {
}
@Override
- public ResourceFile getResourceFile(Pool.ModuleData res) {
+ public ResourceFile getResourceFile(ModuleEntry res) {
return visitPools((AsmModulePool pool) -> {
return pool.getResourceFile(res);
});
}
@Override
- public ClassReader getClassReader(Pool.ModuleData res) {
+ public ClassReader getClassReader(ModuleEntry res) {
return visitPoolsEx((AsmModulePool pool) -> {
return pool.getClassReader(res);
});
@@ -239,7 +239,7 @@ public final class AsmPools {
}
@Override
- public void fillOutputResources(Pool outputResources) {
+ public void fillOutputResources(ModulePool outputResources) {
AsmPools.this.fillOutputResources(outputResources);
}
@@ -324,15 +324,15 @@ public final class AsmPools {
*
* @param inputResources The raw resources to build the pool from.
*/
- public AsmPools(Pool inputResources) {
+ public AsmPools(ModulePool inputResources) {
Objects.requireNonNull(inputResources);
- Map resPools = new LinkedHashMap<>();
+ Map resPools = new LinkedHashMap<>();
Map descriptors = new HashMap<>();
- for (Pool.ModuleData res : inputResources.getContent()) {
- Pool p = resPools.get(res.getModule());
+ inputResources.entries().forEach(res -> {
+ ModulePool p = resPools.get(res.getModule());
if (p == null) {
- p = new PoolImpl(inputResources.getByteOrder(),
- ((PoolImpl)inputResources).getStringTable());
+ p = new ModulePoolImpl(inputResources.getByteOrder(),
+ ((ModulePoolImpl)inputResources).getStringTable());
resPools.put(res.getModule(), p);
}
if (res.getPath().endsWith("module-info.class")) {
@@ -341,11 +341,11 @@ public final class AsmPools {
descriptors.put(res.getModule(), descriptor);
}
p.add(res);
- }
+ });
poolsArray = new AsmModulePool[resPools.size()];
int i = 0;
- for (Entry entry : resPools.entrySet()) {
+ for (Entry entry : resPools.entrySet()) {
ModuleDescriptor descriptor = descriptors.get(entry.getKey());
if (descriptor == null) {
throw new PluginException("module-info.class not found for " + entry.getKey() + " module");
@@ -405,7 +405,7 @@ public final class AsmPools {
*
* @param outputResources The pool used to fill the jimage.
*/
- public void fillOutputResources(Pool outputResources) {
+ public void fillOutputResources(ModulePool outputResources) {
// First sort modules
List