Merge
This commit is contained in:
commit
b334eebe57
jdk
make
src
macosx
bin
classes
com/apple
sun
native/sun
share
bin
classes
com/sun
beans/introspect
java/swing/plaf
gtk
motif
windows
AnimationController.javaDesktopProperty.javaTMSchema.javaWindowsComboBoxUI.javaWindowsFileChooserUI.javaWindowsGraphicsUtils.javaWindowsIconFactory.javaWindowsInternalFrameTitlePane.javaWindowsLookAndFeel.javaWindowsMenuBarUI.javaWindowsMenuItemUI.javaWindowsPopupMenuSeparatorUI.javaWindowsPopupMenuUI.javaWindowsProgressBarUI.javaWindowsSliderUI.javaWindowsSpinnerUI.javaWindowsTableHeaderUI.javaXPStyle.java
jmx
remote
snmp
jndi
cosnaming
ldap
toolkit/corba
security/sasl
tools
example/debug
hat/internal
jdi
java
@ -1358,7 +1358,7 @@ endif
|
||||
ifeq ($(OPENJDK_TARGET_OS), macosx)
|
||||
|
||||
LIBAWT_LWAWT_FILES := \
|
||||
awt.m \
|
||||
AWT_debug.m \
|
||||
ApplicationDelegate.m \
|
||||
CFRetainedResource.m \
|
||||
CGLGraphicsConfig.m \
|
||||
|
@ -35,6 +35,7 @@ SUNWprivate_1.1 {
|
||||
Java_java_awt_SplashScreen__1getImageFileName;
|
||||
Java_java_awt_SplashScreen__1getImageJarName;
|
||||
Java_java_awt_SplashScreen__1setImageData;
|
||||
Java_java_awt_SplashScreen__1getScaleFactor;
|
||||
|
||||
SplashLoadMemory;
|
||||
SplashLoadFile;
|
||||
|
@ -28,10 +28,9 @@
|
||||
SUNWprivate_1.1 {
|
||||
global:
|
||||
Java_sun_security_ec_ECKeyPairGenerator_generateECKeyPair;
|
||||
Java_sun_security_ec_ECKeyPairGenerator_getEncodedBytes;
|
||||
Java_sun_security_ec_ECDSASignature_signDigest;
|
||||
Java_sun_security_ec_ECDSASignature_verifySignedDigest;
|
||||
Java_sun_security_ec_ECDHKeyAgreement_deriveKey;
|
||||
Java_sun_security_ec_ECDSASignature_signDigest;
|
||||
Java_sun_security_ec_ECDSASignature_verifySignedDigest;
|
||||
Java_sun_security_ec_ECDHKeyAgreement_deriveKey;
|
||||
local:
|
||||
*;
|
||||
};
|
||||
|
@ -71,6 +71,7 @@ PROFILE_1_JRE_LIB_FILES := \
|
||||
rt.jar \
|
||||
security/US_export_policy.jar \
|
||||
security/blacklist \
|
||||
security/blacklisted.certs \
|
||||
security/cacerts \
|
||||
security/java.policy \
|
||||
security/java.security \
|
||||
|
@ -994,7 +994,7 @@ SetXStartOnFirstThreadArg()
|
||||
|
||||
sameThread = JNI_TRUE;
|
||||
// Set a variable that tells us we started on the main thread.
|
||||
// This is used by the AWT during startup. (See awt.m)
|
||||
// This is used by the AWT during startup. (See LWCToolkit.m)
|
||||
char envVar[80];
|
||||
snprintf(envVar, sizeof(envVar), "JAVA_STARTED_ON_FIRST_THREAD_%d", getpid());
|
||||
setenv(envVar, "1", 1);
|
||||
|
@ -58,15 +58,8 @@ public class Application {
|
||||
static Application sApplication = null;
|
||||
|
||||
static {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
System.loadLibrary("awt");
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
checkSecurity();
|
||||
Toolkit.getDefaultToolkit(); // Start AppKit
|
||||
if (!Beans.isDesignTime()) {
|
||||
nativeInitializeApplicationDelegate();
|
||||
}
|
||||
|
@ -121,10 +121,6 @@ class AquaComboBoxPopup extends BasicComboPopup {
|
||||
public void show() {
|
||||
final int startItemCount = comboBox.getItemCount();
|
||||
|
||||
if (startItemCount == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Rectangle popupBounds = adjustPopupAndGetBounds();
|
||||
if (popupBounds == null) return; // null means don't show
|
||||
|
||||
|
@ -26,11 +26,14 @@
|
||||
package com.apple.laf;
|
||||
|
||||
import java.awt.*;
|
||||
import java.security.AccessController;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.basic.BasicMenuBarUI;
|
||||
|
||||
import sun.lwawt.macosx.LWCToolkit;
|
||||
import sun.security.action.GetBooleanAction;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
// MenuBar implementation for Mac L&F
|
||||
@ -131,28 +134,20 @@ public class AquaMenuBarUI extends BasicMenuBarUI implements ScreenMenuBarProvid
|
||||
ScreenMenuBar fScreenMenuBar;
|
||||
boolean useScreenMenuBar = getScreenMenuBarProperty();
|
||||
|
||||
private static String getPrivSysProp(final String propName) {
|
||||
return java.security.AccessController.doPrivileged(new GetPropertyAction(propName));
|
||||
}
|
||||
|
||||
static boolean getScreenMenuBarProperty() {
|
||||
final String props[] = new String[]{""};
|
||||
|
||||
boolean useScreenMenuBar = false;
|
||||
try {
|
||||
props[0] = getPrivSysProp(AquaLookAndFeel.sPropertyPrefix + "useScreenMenuBar");
|
||||
|
||||
if (props[0] != null && props[0].equals("true")) useScreenMenuBar = true;
|
||||
else {
|
||||
props[0] = getPrivSysProp(AquaLookAndFeel.sOldPropertyPrefix + "useScreenMenuBar");
|
||||
|
||||
if (props[0] != null && props[0].equals("true")) {
|
||||
System.err.println(AquaLookAndFeel.sOldPropertyPrefix + "useScreenMenuBar has been deprecated. Please switch to " + AquaLookAndFeel.sPropertyPrefix + "useScreenMenuBar");
|
||||
useScreenMenuBar = true;
|
||||
}
|
||||
}
|
||||
} catch(final Throwable t) { };
|
||||
|
||||
return useScreenMenuBar;
|
||||
// Do not allow AWT to set the screen menu bar if it's embedded in another UI toolkit
|
||||
if (LWCToolkit.isEmbedded()) return false;
|
||||
if (AccessController.doPrivileged(
|
||||
new GetBooleanAction(AquaLookAndFeel.sPropertyPrefix + "useScreenMenuBar"))) {
|
||||
return true;
|
||||
}
|
||||
if (AccessController.doPrivileged(
|
||||
new GetBooleanAction(AquaLookAndFeel.sOldPropertyPrefix + "useScreenMenuBar"))) {
|
||||
System.err.println(AquaLookAndFeel.sOldPropertyPrefix +
|
||||
"useScreenMenuBar has been deprecated. Please switch to " +
|
||||
AquaLookAndFeel.sPropertyPrefix + "useScreenMenuBar");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -40,9 +40,6 @@ import sun.java2d.*;
|
||||
*/
|
||||
public final class CGraphicsEnvironment extends SunGraphicsEnvironment {
|
||||
|
||||
// Global initialization of the Cocoa runtime.
|
||||
private static native void initCocoa();
|
||||
|
||||
/**
|
||||
* Fetch an array of all valid CoreGraphics display identifiers.
|
||||
*/
|
||||
@ -60,21 +57,8 @@ public final class CGraphicsEnvironment extends SunGraphicsEnvironment {
|
||||
public static void init() { }
|
||||
|
||||
static {
|
||||
java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
System.loadLibrary("awt");
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
if (isHeadless()) return null;
|
||||
initCocoa();
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
// Load libraries and initialize the Toolkit.
|
||||
Toolkit.getDefaultToolkit();
|
||||
// Install the correct surface manager factory.
|
||||
SurfaceManagerFactory.setInstance(new MacosxSurfaceManagerFactory());
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2014, 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
|
||||
@ -106,6 +106,6 @@ class CFontConfiguration extends FontConfiguration {
|
||||
|
||||
@Override
|
||||
protected void initReorderMap() {
|
||||
reorderMap = new HashMap();
|
||||
reorderMap = new HashMap<>();
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ import java.net.MalformedURLException;
|
||||
|
||||
import sun.awt.*;
|
||||
import sun.awt.datatransfer.DataTransferer;
|
||||
import sun.awt.util.ThreadGroupUtils;
|
||||
import sun.java2d.opengl.OGLRenderQueue;
|
||||
import sun.lwawt.*;
|
||||
import sun.lwawt.LWWindowPeer.PeerType;
|
||||
@ -70,7 +71,7 @@ public final class LWCToolkit extends LWToolkit {
|
||||
private static final int BUTTONS = 5;
|
||||
|
||||
private static native void initIDs();
|
||||
|
||||
private static native void initAppkit(ThreadGroup appKitThreadGroup, boolean headless);
|
||||
private static CInputMethodDescriptor sInputMethodDescriptor;
|
||||
|
||||
static {
|
||||
@ -119,6 +120,7 @@ public final class LWCToolkit extends LWToolkit {
|
||||
areExtraMouseButtonsEnabled = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons", "true"));
|
||||
//set system property if not yet assigned
|
||||
System.setProperty("sun.awt.enableExtraMouseButtons", ""+areExtraMouseButtonsEnabled);
|
||||
initAppkit(ThreadGroupUtils.getRootThreadGroup(), GraphicsEnvironment.isHeadless());
|
||||
}
|
||||
|
||||
/*
|
||||
@ -166,7 +168,7 @@ public final class LWCToolkit extends LWToolkit {
|
||||
// This is only called from native code.
|
||||
static void systemColorsChanged() {
|
||||
EventQueue.invokeLater(() -> {
|
||||
AccessController.doPrivileged ((PrivilegedAction<Object>) () -> {
|
||||
AccessController.doPrivileged( (PrivilegedAction<Object>) () -> {
|
||||
AWTAccessor.getSystemColorAccessor().updateSystemColors();
|
||||
return null;
|
||||
});
|
||||
@ -790,6 +792,13 @@ public final class LWCToolkit extends LWToolkit {
|
||||
*/
|
||||
native boolean isApplicationActive();
|
||||
|
||||
/**
|
||||
* Returns true if AWT toolkit is embedded, false otherwise.
|
||||
*
|
||||
* @return true if AWT toolkit is embedded, false otherwise
|
||||
*/
|
||||
public static native boolean isEmbedded();
|
||||
|
||||
/************************
|
||||
* Native methods section
|
||||
************************/
|
||||
|
@ -30,24 +30,6 @@
|
||||
#import "AWT_debug.h"
|
||||
|
||||
|
||||
/*
|
||||
* Class: sun_awt_CGraphicsEnvironment
|
||||
* Method: initCocoa
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_sun_awt_CGraphicsEnvironment_initCocoa
|
||||
(JNIEnv *env, jclass self)
|
||||
{
|
||||
JNF_COCOA_ENTER(env);
|
||||
|
||||
// Inform Cocoa that we're multi-threaded.
|
||||
// Creating a short-lived NSThread is the recommended way of doing so.
|
||||
[NSThread detachNewThreadSelector:@selector(self) toTarget:[NSObject class] withObject:nil];
|
||||
|
||||
JNF_COCOA_EXIT(env);
|
||||
}
|
||||
|
||||
#define MAX_DISPLAYS 64
|
||||
|
||||
/*
|
||||
|
@ -24,7 +24,12 @@
|
||||
*/
|
||||
|
||||
#import <dlfcn.h>
|
||||
#import <pthread.h>
|
||||
#import <objc/runtime.h>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <Security/AuthSession.h>
|
||||
#import <JavaNativeFoundation/JavaNativeFoundation.h>
|
||||
#import <JavaRuntimeSupport/JavaRuntimeSupport.h>
|
||||
|
||||
#include "jni_util.h"
|
||||
#import "CMenuBar.h"
|
||||
@ -34,6 +39,8 @@
|
||||
#import "AWT_debug.h"
|
||||
#import "CSystemColors.h"
|
||||
#import "NSApplicationAWT.h"
|
||||
#import "PropertiesUtilities.h"
|
||||
#import "ApplicationDelegate.h"
|
||||
|
||||
#import "sun_lwawt_macosx_LWCToolkit.h"
|
||||
|
||||
@ -42,6 +49,20 @@
|
||||
int gNumberOfButtons;
|
||||
jint* gButtonDownMasks;
|
||||
|
||||
// Indicates that the app has been started with -XstartOnFirstThread
|
||||
// (directly or via WebStart settings), and AWT should not run its
|
||||
// own event loop in this mode. Even if a loop isn't running yet,
|
||||
// we expect an embedder (e.g. SWT) to start it some time later.
|
||||
static BOOL forceEmbeddedMode = NO;
|
||||
|
||||
// Indicates if awt toolkit is embedded into another UI toolkit
|
||||
static BOOL isEmbedded = NO;
|
||||
|
||||
// This is the data necessary to have JNI_OnLoad wait for AppKit to start.
|
||||
static BOOL sAppKitStarted = NO;
|
||||
static pthread_mutex_t sAppKitStarted_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_cond_t sAppKitStarted_cv = PTHREAD_COND_INITIALIZER;
|
||||
|
||||
@implementation AWTToolkit
|
||||
|
||||
static long eventCount;
|
||||
@ -115,6 +136,232 @@ static long eventCount;
|
||||
}
|
||||
@end
|
||||
|
||||
void setBusy(BOOL busy) {
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
static JNF_CLASS_CACHE(jc_AWTAutoShutdown, "sun/awt/AWTAutoShutdown");
|
||||
|
||||
if (busy) {
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_notifyBusyMethod, jc_AWTAutoShutdown, "notifyToolkitThreadBusy", "()V");
|
||||
JNFCallStaticVoidMethod(env, jm_notifyBusyMethod);
|
||||
} else {
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_notifyFreeMethod, jc_AWTAutoShutdown, "notifyToolkitThreadFree", "()V");
|
||||
JNFCallStaticVoidMethod(env, jm_notifyFreeMethod);
|
||||
}
|
||||
}
|
||||
|
||||
static void setUpAWTAppKit(BOOL installObservers)
|
||||
{
|
||||
if (installObservers) {
|
||||
AWT_STARTUP_LOG(@"Setting up busy observers");
|
||||
|
||||
// Add CFRunLoopObservers to call into AWT so that AWT knows that the
|
||||
// AWT thread (which is the AppKit main thread) is alive. This way AWT
|
||||
// will not automatically shutdown.
|
||||
CFRunLoopObserverRef busyObserver = CFRunLoopObserverCreateWithHandler(
|
||||
NULL, // CFAllocator
|
||||
kCFRunLoopAfterWaiting, // CFOptionFlags
|
||||
true, // repeats
|
||||
NSIntegerMax, // order
|
||||
^(CFRunLoopObserverRef observer, CFRunLoopActivity activity) {
|
||||
setBusy(YES);
|
||||
});
|
||||
|
||||
CFRunLoopObserverRef notBusyObserver = CFRunLoopObserverCreateWithHandler(
|
||||
NULL, // CFAllocator
|
||||
kCFRunLoopBeforeWaiting, // CFOptionFlags
|
||||
true, // repeats
|
||||
NSIntegerMin, // order
|
||||
^(CFRunLoopObserverRef observer, CFRunLoopActivity activity) {
|
||||
setBusy(NO);
|
||||
});
|
||||
|
||||
CFRunLoopRef runLoop = [[NSRunLoop currentRunLoop] getCFRunLoop];
|
||||
CFRunLoopAddObserver(runLoop, busyObserver, kCFRunLoopDefaultMode);
|
||||
CFRunLoopAddObserver(runLoop, notBusyObserver, kCFRunLoopDefaultMode);
|
||||
|
||||
CFRelease(busyObserver);
|
||||
CFRelease(notBusyObserver);
|
||||
|
||||
setBusy(YES);
|
||||
}
|
||||
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
static JNF_CLASS_CACHE(jc_LWCToolkit, "sun/lwawt/macosx/LWCToolkit");
|
||||
static JNF_STATIC_MEMBER_CACHE(jsm_installToolkitThreadInJava, jc_LWCToolkit, "installToolkitThreadInJava", "()V");
|
||||
JNFCallStaticVoidMethod(env, jsm_installToolkitThreadInJava);
|
||||
}
|
||||
|
||||
BOOL isSWTInWebStart(JNIEnv* env) {
|
||||
NSString *swtWebStart = [PropertiesUtilities javaSystemPropertyForKey:@"com.apple.javaws.usingSWT" withEnv:env];
|
||||
return [@"true" isCaseInsensitiveLike:swtWebStart];
|
||||
}
|
||||
|
||||
static void AWT_NSUncaughtExceptionHandler(NSException *exception) {
|
||||
NSLog(@"Apple AWT Internal Exception: %@", [exception description]);
|
||||
}
|
||||
|
||||
@interface AWTStarter : NSObject
|
||||
+ (void)start:(BOOL)headless;
|
||||
+ (void)starter:(BOOL)onMainThread headless:(BOOL)headless;
|
||||
+ (void)appKitIsRunning:(id)arg;
|
||||
@end
|
||||
|
||||
@implementation AWTStarter
|
||||
|
||||
+ (BOOL) isConnectedToWindowServer {
|
||||
SecuritySessionId session_id;
|
||||
SessionAttributeBits session_info;
|
||||
OSStatus status = SessionGetInfo(callerSecuritySession, &session_id, &session_info);
|
||||
if (status != noErr) return NO;
|
||||
if (!(session_info & sessionHasGraphicAccess)) return NO;
|
||||
return YES;
|
||||
}
|
||||
|
||||
+ (BOOL) markAppAsDaemon {
|
||||
id jrsAppKitAWTClass = objc_getClass("JRSAppKitAWT");
|
||||
SEL markAppSel = @selector(markAppIsDaemon);
|
||||
if (![jrsAppKitAWTClass respondsToSelector:markAppSel]) return NO;
|
||||
return [jrsAppKitAWTClass performSelector:markAppSel] ? YES : NO;
|
||||
}
|
||||
|
||||
+ (void)appKitIsRunning:(id)arg {
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
AWT_STARTUP_LOG(@"About to message AppKit started");
|
||||
|
||||
// Signal that AppKit has started (or is already running).
|
||||
pthread_mutex_lock(&sAppKitStarted_mutex);
|
||||
sAppKitStarted = YES;
|
||||
pthread_cond_signal(&sAppKitStarted_cv);
|
||||
pthread_mutex_unlock(&sAppKitStarted_mutex);
|
||||
|
||||
AWT_STARTUP_LOG(@"Finished messaging AppKit started");
|
||||
}
|
||||
|
||||
+ (void)start:(BOOL)headless
|
||||
{
|
||||
// onMainThread is NOT the same at SWT mode!
|
||||
// If the JVM was started on the first thread for SWT, but the SWT loads the AWT on a secondary thread,
|
||||
// onMainThread here will be false but SWT mode will be true. If we are currently on the main thread, we don't
|
||||
// need to throw AWT startup over to another thread.
|
||||
BOOL onMainThread = [NSThread isMainThread];
|
||||
|
||||
NSString* msg = [NSString stringWithFormat:@"+[AWTStarter start headless:%d] { onMainThread:%d }", headless, onMainThread];
|
||||
AWT_STARTUP_LOG(msg);
|
||||
|
||||
if (!headless)
|
||||
{
|
||||
// Listen for the NSApp to start. This indicates that JNI_OnLoad can proceed.
|
||||
// It must wait because there is a chance that another java thread will grab
|
||||
// the AppKit lock before the +[NSApplication sharedApplication] returns.
|
||||
// See <rdar://problem/3492666> for an example.
|
||||
[[NSNotificationCenter defaultCenter] addObserver:[AWTStarter class]
|
||||
selector:@selector(appKitIsRunning:)
|
||||
name:NSApplicationDidFinishLaunchingNotification
|
||||
object:nil];
|
||||
|
||||
AWT_STARTUP_LOG(@"+[AWTStarter start:::]: registered NSApplicationDidFinishLaunchingNotification");
|
||||
}
|
||||
|
||||
[ThreadUtilities performOnMainThreadWaiting:NO block:^() {
|
||||
[AWTStarter starter:onMainThread headless:headless];
|
||||
}];
|
||||
|
||||
|
||||
if (!headless && !onMainThread) {
|
||||
|
||||
AWT_STARTUP_LOG(@"about to wait on AppKit startup mutex");
|
||||
|
||||
// Wait here for AppKit to have started (or for AWT to have been loaded into
|
||||
// an already running NSApplication).
|
||||
pthread_mutex_lock(&sAppKitStarted_mutex);
|
||||
while (sAppKitStarted == NO) {
|
||||
pthread_cond_wait(&sAppKitStarted_cv, &sAppKitStarted_mutex);
|
||||
}
|
||||
pthread_mutex_unlock(&sAppKitStarted_mutex);
|
||||
|
||||
// AWT gets here AFTER +[AWTStarter appKitIsRunning:] is called.
|
||||
AWT_STARTUP_LOG(@"got out of the AppKit startup mutex");
|
||||
}
|
||||
|
||||
if (!headless) {
|
||||
// Don't set the delegate until the NSApplication has been created and
|
||||
// its finishLaunching has initialized it.
|
||||
// ApplicationDelegate is the support code for com.apple.eawt.
|
||||
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
|
||||
id<NSApplicationDelegate> delegate = [ApplicationDelegate sharedDelegate];
|
||||
if (delegate != nil) {
|
||||
OSXAPP_SetApplicationDelegate(delegate);
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)starter:(BOOL)wasOnMainThread headless:(BOOL)headless {
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
// Add the exception handler of last resort
|
||||
NSSetUncaughtExceptionHandler(AWT_NSUncaughtExceptionHandler);
|
||||
|
||||
// Headless mode trumps either ordinary AWT or SWT-in-AWT mode. Declare us a daemon and return.
|
||||
if (headless) {
|
||||
// Note that we don't install run loop observers in headless mode
|
||||
// because we don't need them (see 7174704)
|
||||
if (!forceEmbeddedMode) {
|
||||
setUpAWTAppKit(false);
|
||||
}
|
||||
[AWTStarter markAppAsDaemon];
|
||||
return;
|
||||
}
|
||||
|
||||
if (forceEmbeddedMode) {
|
||||
AWT_STARTUP_LOG(@"in SWT or SWT/WebStart mode");
|
||||
|
||||
// Init a default NSApplication instance instead of the NSApplicationAWT.
|
||||
// Note that [NSApp isRunning] will return YES after that, though
|
||||
// this behavior isn't specified anywhere. We rely on that.
|
||||
NSApplicationLoad();
|
||||
}
|
||||
|
||||
// This will create a NSApplicationAWT for standalone AWT programs, unless there is
|
||||
// already a NSApplication instance. If there is already a NSApplication instance,
|
||||
// and -[NSApplication isRunning] returns YES, AWT is embedded inside another
|
||||
// AppKit Application.
|
||||
NSApplication *app = [NSApplicationAWT sharedApplication];
|
||||
isEmbedded = ![NSApp isKindOfClass:[NSApplicationAWT class]];
|
||||
|
||||
if (!isEmbedded) {
|
||||
// Install run loop observers and set the AppKit Java thread name
|
||||
setUpAWTAppKit(true);
|
||||
}
|
||||
|
||||
// AWT gets to this point BEFORE NSApplicationDidFinishLaunchingNotification is sent.
|
||||
if (![app isRunning]) {
|
||||
AWT_STARTUP_LOG(@"+[AWTStarter startAWT]: ![app isRunning]");
|
||||
// This is where the AWT AppKit thread parks itself to process events.
|
||||
[NSApplicationAWT runAWTLoopWithApp: app];
|
||||
} else {
|
||||
// We're either embedded, or showing a splash screen
|
||||
if (isEmbedded) {
|
||||
AWT_STARTUP_LOG(@"running embedded");
|
||||
|
||||
// We don't track if the runloop is busy, so set it free to let AWT finish when it needs
|
||||
setBusy(NO);
|
||||
} else {
|
||||
AWT_STARTUP_LOG(@"running after showing a splash screen");
|
||||
}
|
||||
|
||||
// Signal so that JNI_OnLoad can proceed.
|
||||
if (!wasOnMainThread) [AWTStarter appKitIsRunning:nil];
|
||||
|
||||
// Proceed to exit this call as there is no reason to run the NSApplication event loop.
|
||||
}
|
||||
|
||||
[pool drain];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_LWCToolkit
|
||||
* Method: nativeSyncQueue
|
||||
@ -169,52 +416,6 @@ Java_sun_lwawt_macosx_LWCToolkit_beep
|
||||
NSBeep(); // produces both sound and visual flash, if configured in System Preferences
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_LWCToolkit
|
||||
* Method: initIDs
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_sun_lwawt_macosx_LWCToolkit_initIDs
|
||||
(JNIEnv *env, jclass klass) {
|
||||
// set thread names
|
||||
if (![ThreadUtilities isAWTEmbedded]) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^(void){
|
||||
[[NSThread currentThread] setName:@"AppKit Thread"];
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
static JNF_CLASS_CACHE(jc_LWCToolkit, "sun/lwawt/macosx/LWCToolkit");
|
||||
static JNF_STATIC_MEMBER_CACHE(jsm_installToolkitThreadInJava, jc_LWCToolkit, "installToolkitThreadInJava", "()V");
|
||||
JNFCallStaticVoidMethod(env, jsm_installToolkitThreadInJava);
|
||||
});
|
||||
}
|
||||
|
||||
gNumberOfButtons = sun_lwawt_macosx_LWCToolkit_BUTTONS;
|
||||
|
||||
jclass inputEventClazz = (*env)->FindClass(env, "java/awt/event/InputEvent");
|
||||
CHECK_NULL(inputEventClazz);
|
||||
jmethodID getButtonDownMasksID = (*env)->GetStaticMethodID(env, inputEventClazz, "getButtonDownMasks", "()[I");
|
||||
CHECK_NULL(getButtonDownMasksID);
|
||||
jintArray obj = (jintArray)(*env)->CallStaticObjectMethod(env, inputEventClazz, getButtonDownMasksID);
|
||||
jint * tmp = (*env)->GetIntArrayElements(env, obj, JNI_FALSE);
|
||||
CHECK_NULL(tmp);
|
||||
|
||||
gButtonDownMasks = (jint*)SAFE_SIZE_ARRAY_ALLOC(malloc, sizeof(jint), gNumberOfButtons);
|
||||
if (gButtonDownMasks == NULL) {
|
||||
gNumberOfButtons = 0;
|
||||
(*env)->ReleaseIntArrayElements(env, obj, tmp, JNI_ABORT);
|
||||
JNU_ThrowOutOfMemoryError(env, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
int i;
|
||||
for (i = 0; i < gNumberOfButtons; i++) {
|
||||
gButtonDownMasks[i] = tmp[i];
|
||||
}
|
||||
|
||||
(*env)->ReleaseIntArrayElements(env, obj, tmp, 0);
|
||||
(*env)->DeleteLocalRef(env, obj);
|
||||
}
|
||||
|
||||
static UInt32 RGB(NSColor *c) {
|
||||
c = [c colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
||||
if (c == nil)
|
||||
@ -443,3 +644,95 @@ Java_sun_font_FontManager_populateFontFileNameMap
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_LWCToolkit
|
||||
* Method: initIDs
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_sun_lwawt_macosx_LWCToolkit_initIDs
|
||||
(JNIEnv *env, jclass klass) {
|
||||
|
||||
JNF_COCOA_ENTER(env)
|
||||
|
||||
gNumberOfButtons = sun_lwawt_macosx_LWCToolkit_BUTTONS;
|
||||
|
||||
jclass inputEventClazz = (*env)->FindClass(env, "java/awt/event/InputEvent");
|
||||
CHECK_NULL(inputEventClazz);
|
||||
jmethodID getButtonDownMasksID = (*env)->GetStaticMethodID(env, inputEventClazz, "getButtonDownMasks", "()[I");
|
||||
CHECK_NULL(getButtonDownMasksID);
|
||||
jintArray obj = (jintArray)(*env)->CallStaticObjectMethod(env, inputEventClazz, getButtonDownMasksID);
|
||||
jint * tmp = (*env)->GetIntArrayElements(env, obj, JNI_FALSE);
|
||||
CHECK_NULL(tmp);
|
||||
|
||||
gButtonDownMasks = (jint*)SAFE_SIZE_ARRAY_ALLOC(malloc, sizeof(jint), gNumberOfButtons);
|
||||
if (gButtonDownMasks == NULL) {
|
||||
gNumberOfButtons = 0;
|
||||
(*env)->ReleaseIntArrayElements(env, obj, tmp, JNI_ABORT);
|
||||
JNU_ThrowOutOfMemoryError(env, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
int i;
|
||||
for (i = 0; i < gNumberOfButtons; i++) {
|
||||
gButtonDownMasks[i] = tmp[i];
|
||||
}
|
||||
|
||||
(*env)->ReleaseIntArrayElements(env, obj, tmp, 0);
|
||||
(*env)->DeleteLocalRef(env, obj);
|
||||
|
||||
JNF_COCOA_EXIT(env)
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_LWCToolkit
|
||||
* Method: initAppkit
|
||||
* Signature: (Ljava/lang/ThreadGroup;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_sun_lwawt_macosx_LWCToolkit_initAppkit
|
||||
(JNIEnv *env, jclass klass, jobject appkitThreadGroup, jboolean headless) {
|
||||
JNF_COCOA_ENTER(env)
|
||||
|
||||
[ThreadUtilities setAppkitThreadGroup:(*env)->NewGlobalRef(env, appkitThreadGroup)];
|
||||
|
||||
// Launcher sets this env variable if -XstartOnFirstThread is specified
|
||||
char envVar[80];
|
||||
snprintf(envVar, sizeof(envVar), "JAVA_STARTED_ON_FIRST_THREAD_%d", getpid());
|
||||
if (getenv(envVar) != NULL) {
|
||||
forceEmbeddedMode = YES;
|
||||
unsetenv(envVar);
|
||||
}
|
||||
|
||||
if (isSWTInWebStart(env)) {
|
||||
forceEmbeddedMode = YES;
|
||||
}
|
||||
|
||||
[AWTStarter start:headless ? YES : NO];
|
||||
|
||||
JNF_COCOA_EXIT(env)
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
OSXAPP_SetJavaVM(vm);
|
||||
|
||||
// We need to let Foundation know that this is a multithreaded application, if it isn't already.
|
||||
if (![NSThread isMultiThreaded]) {
|
||||
[NSThread detachNewThreadSelector:nil toTarget:nil withObject:nil];
|
||||
}
|
||||
|
||||
return JNI_VERSION_1_4;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_LWCToolkit
|
||||
* Method: isEmbedded
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_sun_lwawt_macosx_LWCToolkit_isEmbedded
|
||||
(JNIEnv *env, jclass klass) {
|
||||
return isEmbedded ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
|
||||
|
@ -1,460 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2013, 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.
|
||||
*/
|
||||
|
||||
#import <pthread.h>
|
||||
#import <objc/runtime.h>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <Security/AuthSession.h>
|
||||
#import <JavaNativeFoundation/JavaNativeFoundation.h>
|
||||
#import <JavaRuntimeSupport/JavaRuntimeSupport.h>
|
||||
|
||||
#import "NSApplicationAWT.h"
|
||||
#import "PropertiesUtilities.h"
|
||||
#import "ThreadUtilities.h"
|
||||
#import "AWT_debug.h"
|
||||
#import "ApplicationDelegate.h"
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
|
||||
// The symbol is defined in libosxapp.dylib (ThreadUtilities.m)
|
||||
extern JavaVM *jvm;
|
||||
|
||||
// Indicates if AWT is running embedded (in SWT, FX, elsewhere)
|
||||
static BOOL isEmbedded = NO;
|
||||
|
||||
// Indicates that the app has been started with -XstartOnFirstThread
|
||||
// (directly or via WebStart settings), and AWT should not run its
|
||||
// own event loop in this mode. Even if a loop isn't running yet,
|
||||
// we expect an embedder (e.g. SWT) to start it some time later.
|
||||
static BOOL forceEmbeddedMode = NO;
|
||||
|
||||
static bool ShouldPrintVerboseDebugging() {
|
||||
static int debug = -1;
|
||||
if (debug == -1) {
|
||||
debug = (int)(getenv("JAVA_AWT_VERBOSE") != NULL) || (DEBUG != 0);
|
||||
}
|
||||
return (bool)debug;
|
||||
}
|
||||
|
||||
// This is the data necessary to have JNI_OnLoad wait for AppKit to start.
|
||||
static BOOL sAppKitStarted = NO;
|
||||
static pthread_mutex_t sAppKitStarted_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_cond_t sAppKitStarted_cv = PTHREAD_COND_INITIALIZER;
|
||||
|
||||
void setBusy(BOOL isBusy);
|
||||
static void BusyObserver(CFRunLoopObserverRef ref, CFRunLoopActivity what, void* arg);
|
||||
static void NotBusyObserver(CFRunLoopObserverRef ref, CFRunLoopActivity what, void* arg);
|
||||
static void AWT_NSUncaughtExceptionHandler(NSException *exception);
|
||||
|
||||
static CFRunLoopObserverRef busyObserver = NULL;
|
||||
static CFRunLoopObserverRef notBusyObserver = NULL;
|
||||
|
||||
static void setUpAWTAppKit()
|
||||
{
|
||||
BOOL verbose = ShouldPrintVerboseDebugging();
|
||||
if (verbose) AWT_DEBUG_LOG(@"setting up busy observers");
|
||||
|
||||
// Add CFRunLoopObservers to call into AWT so that AWT knows that the
|
||||
// AWT thread (which is the AppKit main thread) is alive. This way AWT
|
||||
// will not automatically shutdown.
|
||||
busyObserver = CFRunLoopObserverCreate(
|
||||
NULL, // CFAllocator
|
||||
kCFRunLoopAfterWaiting, // CFOptionFlags
|
||||
true, // repeats
|
||||
NSIntegerMax, // order
|
||||
&BusyObserver, // CFRunLoopObserverCallBack
|
||||
NULL); // CFRunLoopObserverContext
|
||||
|
||||
notBusyObserver = CFRunLoopObserverCreate(
|
||||
NULL, // CFAllocator
|
||||
kCFRunLoopBeforeWaiting, // CFOptionFlags
|
||||
true, // repeats
|
||||
NSIntegerMin, // order
|
||||
&NotBusyObserver, // CFRunLoopObserverCallBack
|
||||
NULL); // CFRunLoopObserverContext
|
||||
|
||||
CFRunLoopRef runLoop = [[NSRunLoop currentRunLoop] getCFRunLoop];
|
||||
CFRunLoopAddObserver(runLoop, busyObserver, kCFRunLoopDefaultMode);
|
||||
CFRunLoopAddObserver(runLoop, notBusyObserver, kCFRunLoopDefaultMode);
|
||||
|
||||
CFRelease(busyObserver);
|
||||
CFRelease(notBusyObserver);
|
||||
|
||||
setBusy(YES);
|
||||
}
|
||||
|
||||
static void setUpAppKitThreadName()
|
||||
{
|
||||
BOOL verbose = ShouldPrintVerboseDebugging();
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
|
||||
// Set the java name of the AppKit main thread appropriately.
|
||||
jclass threadClass = NULL;
|
||||
jstring name = NULL;
|
||||
jobject curThread = NULL;
|
||||
|
||||
threadClass = (*env)->FindClass(env, "java/lang/Thread");
|
||||
if (threadClass == NULL || (*env)->ExceptionCheck(env)) goto cleanup;
|
||||
jmethodID currentThreadID = (*env)->GetStaticMethodID(env, threadClass, "currentThread", "()Ljava/lang/Thread;");
|
||||
if (currentThreadID == NULL || (*env)->ExceptionCheck(env)) goto cleanup;
|
||||
jmethodID setName = (*env)->GetMethodID(env, threadClass, "setName", "(Ljava/lang/String;)V");
|
||||
if (setName == NULL || (*env)->ExceptionCheck(env)) goto cleanup;
|
||||
|
||||
curThread = (*env)->CallStaticObjectMethod(env, threadClass, currentThreadID); // AWT_THREADING Safe (known object)
|
||||
if (curThread == NULL || (*env)->ExceptionCheck(env)) goto cleanup;
|
||||
name = (*env)->NewStringUTF(env, "AWT-AppKit");
|
||||
if (name == NULL || (*env)->ExceptionCheck(env)) goto cleanup;
|
||||
(*env)->CallVoidMethod(env, curThread, setName, name); // AWT_THREADING Safe (known object)
|
||||
if ((*env)->ExceptionCheck(env)) goto cleanup;
|
||||
|
||||
cleanup:
|
||||
if (threadClass != NULL) {
|
||||
(*env)->DeleteLocalRef(env, threadClass);
|
||||
}
|
||||
if (name != NULL) {
|
||||
(*env)->DeleteLocalRef(env, name);
|
||||
}
|
||||
if (curThread != NULL) {
|
||||
(*env)->DeleteLocalRef(env, curThread);
|
||||
}
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
(*env)->ExceptionDescribe(env);
|
||||
(*env)->ExceptionClear(env);
|
||||
}
|
||||
|
||||
if (verbose) AWT_DEBUG_LOG(@"finished setting thread name");
|
||||
}
|
||||
|
||||
|
||||
// Returns true if java believes it is running headless
|
||||
BOOL isHeadless(JNIEnv *env) {
|
||||
// Just access the property directly, instead of using GraphicsEnvironment.isHeadless.
|
||||
// This is because this may be called while AWT is being loaded, and calling AWT
|
||||
// while it is being loaded will deadlock.
|
||||
static JNF_CLASS_CACHE(jc_Toolkit, "java/awt/GraphicsEnvironment");
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_isHeadless, jc_Toolkit, "isHeadless", "()Z");
|
||||
return JNFCallStaticBooleanMethod(env, jm_isHeadless);
|
||||
}
|
||||
|
||||
BOOL isSWTInWebStart(JNIEnv* env) {
|
||||
NSString *swtWebStart = [PropertiesUtilities javaSystemPropertyForKey:@"com.apple.javaws.usingSWT" withEnv:env];
|
||||
return [@"true" isCaseInsensitiveLike:swtWebStart];
|
||||
}
|
||||
|
||||
void setBusy(BOOL busy) {
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
static JNF_CLASS_CACHE(jc_AWTAutoShutdown, "sun/awt/AWTAutoShutdown");
|
||||
|
||||
if (busy) {
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_notifyBusyMethod, jc_AWTAutoShutdown, "notifyToolkitThreadBusy", "()V");
|
||||
JNFCallStaticVoidMethod(env, jm_notifyBusyMethod);
|
||||
} else {
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_notifyFreeMethod, jc_AWTAutoShutdown, "notifyToolkitThreadFree", "()V");
|
||||
JNFCallStaticVoidMethod(env, jm_notifyFreeMethod);
|
||||
}
|
||||
}
|
||||
|
||||
static void BusyObserver(CFRunLoopObserverRef ref, CFRunLoopActivity what, void* arg) {
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
|
||||
// This is only called with the selector kCFRunLoopAfterWaiting.
|
||||
#ifndef PRODUCT_BUILD
|
||||
assert(what == kCFRunLoopAfterWaiting);
|
||||
#endif /* PRODUCT_BUILD */
|
||||
|
||||
setBusy(YES);
|
||||
}
|
||||
|
||||
static void NotBusyObserver(CFRunLoopObserverRef ref, CFRunLoopActivity what, void* arg) {
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
|
||||
// This is only called with the selector kCFRunLoopBeforeWaiting.
|
||||
#ifndef PRODUCT_BUILD
|
||||
assert(what == kCFRunLoopBeforeWaiting);
|
||||
#endif /* PRODUCT_BUILD */
|
||||
|
||||
setBusy(NO);
|
||||
}
|
||||
|
||||
static void AWT_NSUncaughtExceptionHandler(NSException *exception) {
|
||||
NSLog(@"Apple AWT Internal Exception: %@", [exception description]);
|
||||
}
|
||||
|
||||
// This is an empty Obj-C object just so that -peformSelectorOnMainThread can be used.
|
||||
@interface AWTStarter : NSObject { }
|
||||
+ (void)start:(BOOL)headless;
|
||||
- (void)starter:(NSArray*)args;
|
||||
+ (void)appKitIsRunning:(id)arg;
|
||||
@end
|
||||
|
||||
@implementation AWTStarter
|
||||
|
||||
+ (BOOL) isConnectedToWindowServer {
|
||||
SecuritySessionId session_id;
|
||||
SessionAttributeBits session_info;
|
||||
OSStatus status = SessionGetInfo(callerSecuritySession, &session_id, &session_info);
|
||||
if (status != noErr) return NO;
|
||||
if (!(session_info & sessionHasGraphicAccess)) return NO;
|
||||
return YES;
|
||||
}
|
||||
|
||||
+ (BOOL) markAppAsDaemon {
|
||||
id jrsAppKitAWTClass = objc_getClass("JRSAppKitAWT");
|
||||
SEL markAppSel = @selector(markAppIsDaemon);
|
||||
if (![jrsAppKitAWTClass respondsToSelector:markAppSel]) return NO;
|
||||
return [jrsAppKitAWTClass performSelector:markAppSel] ? YES : NO;
|
||||
}
|
||||
|
||||
+ (void)appKitIsRunning:(id)arg {
|
||||
// Headless: NO
|
||||
// Embedded: BOTH
|
||||
// Multiple Calls: NO
|
||||
// Callers: AppKit's NSApplicationDidFinishLaunchingNotification or +[AWTStarter startAWT:]
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
|
||||
BOOL verbose = ShouldPrintVerboseDebugging();
|
||||
if (verbose) AWT_DEBUG_LOG(@"about to message AppKit started");
|
||||
|
||||
// Signal that AppKit has started (or is already running).
|
||||
pthread_mutex_lock(&sAppKitStarted_mutex);
|
||||
sAppKitStarted = YES;
|
||||
pthread_cond_signal(&sAppKitStarted_cv);
|
||||
pthread_mutex_unlock(&sAppKitStarted_mutex);
|
||||
|
||||
if (verbose) AWT_DEBUG_LOG(@"finished messaging AppKit started");
|
||||
}
|
||||
|
||||
+ (void)start:(BOOL)headless
|
||||
{
|
||||
BOOL verbose = ShouldPrintVerboseDebugging();
|
||||
|
||||
// Headless: BOTH
|
||||
// Embedded: BOTH
|
||||
// Multiple Calls: NO
|
||||
// Caller: JNI_OnLoad
|
||||
|
||||
// onMainThread is NOT the same at SWT mode!
|
||||
// If the JVM was started on the first thread for SWT, but the SWT loads the AWT on a secondary thread,
|
||||
// onMainThread here will be false but SWT mode will be true. If we are currently on the main thread, we don't
|
||||
// need to throw AWT startup over to another thread.
|
||||
BOOL onMainThread = (pthread_main_np() != 0);
|
||||
|
||||
if (verbose) {
|
||||
NSString *msg = [NSString stringWithFormat:@"+[AWTStarter start headless:%d] { onMainThread:%d }", headless, onMainThread];
|
||||
AWT_DEBUG_LOG(msg);
|
||||
}
|
||||
|
||||
if (!headless)
|
||||
{
|
||||
// Listen for the NSApp to start. This indicates that JNI_OnLoad can proceed.
|
||||
// It must wait because there is a chance that another java thread will grab
|
||||
// the AppKit lock before the +[NSApplication sharedApplication] returns.
|
||||
// See <rdar://problem/3492666> for an example.
|
||||
[[NSNotificationCenter defaultCenter] addObserver:[AWTStarter class]
|
||||
selector:@selector(appKitIsRunning:)
|
||||
name:NSApplicationDidFinishLaunchingNotification
|
||||
object:nil];
|
||||
|
||||
if (verbose) NSLog(@"+[AWTStarter start:::]: registered NSApplicationDidFinishLaunchingNotification");
|
||||
}
|
||||
|
||||
id st = [[AWTStarter alloc] init];
|
||||
|
||||
NSArray * args = [NSArray arrayWithObjects:
|
||||
[NSNumber numberWithBool: onMainThread],
|
||||
[NSNumber numberWithBool: headless],
|
||||
[NSNumber numberWithBool: verbose],
|
||||
nil];
|
||||
|
||||
if (onMainThread) {
|
||||
[st starter:args];
|
||||
} else {
|
||||
[st performSelectorOnMainThread: @selector(starter:) withObject:args waitUntilDone:NO];
|
||||
}
|
||||
|
||||
if (!headless && !onMainThread) {
|
||||
if (verbose) AWT_DEBUG_LOG(@"about to wait on AppKit startup mutex");
|
||||
|
||||
// Wait here for AppKit to have started (or for AWT to have been loaded into
|
||||
// an already running NSApplication).
|
||||
pthread_mutex_lock(&sAppKitStarted_mutex);
|
||||
while (sAppKitStarted == NO) {
|
||||
pthread_cond_wait(&sAppKitStarted_cv, &sAppKitStarted_mutex);
|
||||
}
|
||||
pthread_mutex_unlock(&sAppKitStarted_mutex);
|
||||
|
||||
// AWT gets here AFTER +[AWTStarter appKitIsRunning:] is called.
|
||||
if (verbose) AWT_DEBUG_LOG(@"got out of the AppKit startup mutex");
|
||||
}
|
||||
|
||||
if (!headless) {
|
||||
// Don't set the delegate until the NSApplication has been created and
|
||||
// its finishLaunching has initialized it.
|
||||
// ApplicationDelegate is the support code for com.apple.eawt.
|
||||
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
|
||||
id<NSApplicationDelegate> delegate = [ApplicationDelegate sharedDelegate];
|
||||
if (delegate != nil) {
|
||||
OSXAPP_SetApplicationDelegate(delegate);
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)starter:(NSArray*)args {
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
|
||||
BOOL onMainThread = [[args objectAtIndex:0] boolValue];
|
||||
BOOL headless = [[args objectAtIndex:1] boolValue];
|
||||
BOOL verbose = [[args objectAtIndex:2] boolValue];
|
||||
|
||||
BOOL wasOnMainThread = onMainThread;
|
||||
|
||||
// Add the exception handler of last resort
|
||||
NSSetUncaughtExceptionHandler(AWT_NSUncaughtExceptionHandler);
|
||||
|
||||
// Headless mode trumps either ordinary AWT or SWT-in-AWT mode. Declare us a daemon and return.
|
||||
if (headless) {
|
||||
// Note that we don't install run loop observers in headless mode
|
||||
// because we don't need them (see 7174704)
|
||||
if (!forceEmbeddedMode) {
|
||||
setUpAppKitThreadName();
|
||||
}
|
||||
[AWTStarter markAppAsDaemon];
|
||||
return;
|
||||
}
|
||||
|
||||
if (forceEmbeddedMode) {
|
||||
if (verbose) NSLog(@"in SWT or SWT/WebStart mode");
|
||||
|
||||
// Init a default NSApplication instance instead of the NSApplicationAWT.
|
||||
// Note that [NSApp isRunning] will return YES after that, though
|
||||
// this behavior isn't specified anywhere. We rely on that.
|
||||
NSApplicationLoad();
|
||||
}
|
||||
|
||||
// This will create a NSApplicationAWT for standalone AWT programs, unless there is
|
||||
// already a NSApplication instance. If there is already a NSApplication instance,
|
||||
// and -[NSApplication isRunning] returns YES, AWT is embedded inside another
|
||||
// AppKit Application.
|
||||
NSApplication *app = [NSApplicationAWT sharedApplication];
|
||||
isEmbedded = ![NSApp isKindOfClass:[NSApplicationAWT class]];
|
||||
[ThreadUtilities setAWTEmbedded:isEmbedded];
|
||||
|
||||
if (!isEmbedded) {
|
||||
// Install run loop observers and set the AppKit Java thread name
|
||||
setUpAWTAppKit();
|
||||
setUpAppKitThreadName();
|
||||
}
|
||||
|
||||
// AWT gets to this point BEFORE NSApplicationDidFinishLaunchingNotification is sent.
|
||||
if (![app isRunning]) {
|
||||
if (verbose) AWT_DEBUG_LOG(@"+[AWTStarter startAWT]: ![app isRunning]");
|
||||
|
||||
// This is where the AWT AppKit thread parks itself to process events.
|
||||
[NSApplicationAWT runAWTLoopWithApp: app];
|
||||
} else {
|
||||
// We're either embedded, or showing a splash screen
|
||||
if (isEmbedded) {
|
||||
if (verbose) AWT_DEBUG_LOG(@"running embedded");
|
||||
|
||||
// We don't track if the runloop is busy, so set it free to let AWT finish when it needs
|
||||
setBusy(NO);
|
||||
} else {
|
||||
if (verbose) AWT_DEBUG_LOG(@"running after showing a splash screen");
|
||||
}
|
||||
|
||||
// Signal so that JNI_OnLoad can proceed.
|
||||
if (!wasOnMainThread) [AWTStarter appKitIsRunning:nil];
|
||||
|
||||
// Proceed to exit this call as there is no reason to run the NSApplication event loop.
|
||||
}
|
||||
|
||||
[pool drain];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
BOOL verbose = ShouldPrintVerboseDebugging();
|
||||
if (verbose) AWT_DEBUG_LOG(@"entered JNI_OnLoad");
|
||||
|
||||
// Headless: BOTH
|
||||
// Embedded: BOTH
|
||||
// Multiple Calls: NO
|
||||
// Caller: JavaVM classloader
|
||||
|
||||
// Keep a static reference for other archives.
|
||||
OSXAPP_SetJavaVM(vm);
|
||||
|
||||
JNIEnv *env = NULL;
|
||||
|
||||
// Need JNIEnv for JNF_COCOA_ENTER(env); macro below
|
||||
jint status = (*jvm)->GetEnv(jvm, (void **)&env, JNI_VERSION_1_4);
|
||||
if (status != JNI_OK || env == NULL) {
|
||||
AWT_DEBUG_LOG(@"Can't get JNIEnv");
|
||||
return JNI_VERSION_1_4;
|
||||
}
|
||||
|
||||
JNF_COCOA_ENTER(env);
|
||||
|
||||
// Launcher sets this env variable if -XstartOnFirstThread is specified
|
||||
char envVar[80];
|
||||
snprintf(envVar, sizeof(envVar), "JAVA_STARTED_ON_FIRST_THREAD_%d", getpid());
|
||||
if (getenv(envVar) != NULL) {
|
||||
forceEmbeddedMode = YES;
|
||||
unsetenv(envVar);
|
||||
}
|
||||
|
||||
if (isSWTInWebStart(env)) {
|
||||
forceEmbeddedMode = YES;
|
||||
}
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnvUncached];
|
||||
jclass jc_ThreadGroupUtils = (*env)->FindClass(env, "sun/awt/util/ThreadGroupUtils");
|
||||
jmethodID sjm_getRootThreadGroup = (*env)->GetStaticMethodID(env, jc_ThreadGroupUtils, "getRootThreadGroup", "()Ljava/lang/ThreadGroup;");
|
||||
jobject rootThreadGroup = (*env)->CallStaticObjectMethod(env, jc_ThreadGroupUtils, sjm_getRootThreadGroup);
|
||||
[ThreadUtilities setAppkitThreadGroup:(*env)->NewGlobalRef(env, rootThreadGroup)];
|
||||
// The current thread was attached in getJNIEnvUnchached.
|
||||
// Detach it back. It will be reattached later if needed with a proper TG
|
||||
[ThreadUtilities detachCurrentThread];
|
||||
|
||||
BOOL headless = isHeadless(env);
|
||||
|
||||
// We need to let Foundation know that this is a multithreaded application, if it isn't already.
|
||||
if (![NSThread isMultiThreaded]) {
|
||||
[NSThread detachNewThreadSelector:nil toTarget:nil withObject:nil];
|
||||
}
|
||||
|
||||
[AWTStarter start:headless];
|
||||
|
||||
JNF_COCOA_EXIT(env);
|
||||
|
||||
if (verbose) AWT_DEBUG_LOG(@"exiting JNI_OnLoad");
|
||||
|
||||
return JNI_VERSION_1_4;
|
||||
}
|
@ -125,6 +125,39 @@ done:
|
||||
return buf;
|
||||
}
|
||||
|
||||
char* SplashGetScaledImageName(const char* jar, const char* file,
|
||||
float *scaleFactor) {
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
*scaleFactor = 1;
|
||||
char* scaledFile = nil;
|
||||
float screenScaleFactor = [SplashNSScreen() backingScaleFactor];
|
||||
|
||||
if (screenScaleFactor > 1) {
|
||||
NSString *fileName = [NSString stringWithUTF8String: file];
|
||||
NSUInteger length = [fileName length];
|
||||
NSRange range = [fileName rangeOfString: @"."
|
||||
options:NSBackwardsSearch];
|
||||
NSUInteger dotIndex = range.location;
|
||||
NSString *fileName2x = nil;
|
||||
|
||||
if (dotIndex == NSNotFound) {
|
||||
fileName2x = [fileName stringByAppendingString: @"@2x"];
|
||||
} else {
|
||||
fileName2x = [fileName substringToIndex: dotIndex];
|
||||
fileName2x = [fileName2x stringByAppendingString: @"@2x"];
|
||||
fileName2x = [fileName2x stringByAppendingString:
|
||||
[fileName substringFromIndex: dotIndex]];
|
||||
}
|
||||
|
||||
if ((fileName2x != nil) && (jar || [[NSFileManager defaultManager]
|
||||
fileExistsAtPath: fileName2x])){
|
||||
*scaleFactor = 2;
|
||||
scaledFile = strdup([fileName2x UTF8String]);
|
||||
}
|
||||
}
|
||||
[pool drain];
|
||||
return scaledFile;
|
||||
}
|
||||
|
||||
void
|
||||
SplashInitPlatform(Splash * splash) {
|
||||
@ -132,7 +165,7 @@ SplashInitPlatform(Splash * splash) {
|
||||
|
||||
splash->maskRequired = 0;
|
||||
|
||||
|
||||
|
||||
//TODO: the following is too much of a hack but should work in 90% cases.
|
||||
// besides we don't use device-dependant drawing, so probably
|
||||
// that's very fine indeed
|
||||
@ -225,7 +258,15 @@ SplashRedrawWindow(Splash * splash) {
|
||||
[image setBackgroundColor: [NSColor clearColor]];
|
||||
|
||||
[image addRepresentation: rep];
|
||||
|
||||
float scaleFactor = splash->scaleFactor;
|
||||
if (scaleFactor > 0 && scaleFactor != 1) {
|
||||
[image setScalesWhenResized:YES];
|
||||
NSSize size = [image size];
|
||||
size.width /= scaleFactor;
|
||||
size.height /= scaleFactor;
|
||||
[image setSize: size];
|
||||
}
|
||||
|
||||
NSImageView * view = [[NSImageView alloc] init];
|
||||
|
||||
[view setImage: image];
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2014, 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
|
||||
@ -28,12 +28,16 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
bool ShouldPrintVerboseDebugging();
|
||||
|
||||
#define kInternalError "java/lang/InternalError"
|
||||
|
||||
#define AWT_DEBUG_LOG(str) \
|
||||
NSLog(@"\tCocoa AWT: %@ %@", str, [NSThread callStackSymbols])
|
||||
|
||||
#define AWT_STARTUP_LOG(str) \
|
||||
if (ShouldPrintVerboseDebugging()) AWT_DEBUG_LOG((str))
|
||||
|
||||
#define AWT_DEBUG_BUG_REPORT_MESSAGE \
|
||||
NSLog(@"\tPlease file a bug report at http://bugreport.java.com/bugreport \
|
||||
with this message and a reproducible test case.")
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 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
|
||||
@ -23,13 +23,12 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.awt;
|
||||
#import "AWT_debug.h"
|
||||
|
||||
/**
|
||||
* Interface for identifying and casting toolkits that support
|
||||
* WindowClosingListeners.
|
||||
*/
|
||||
public interface WindowClosingSupport {
|
||||
WindowClosingListener getWindowClosingListener();
|
||||
void setWindowClosingListener(WindowClosingListener wcl);
|
||||
bool ShouldPrintVerboseDebugging() {
|
||||
static int debug = -1;
|
||||
if (debug == -1) {
|
||||
debug = (int)(getenv("JAVA_AWT_VERBOSE") != NULL);
|
||||
}
|
||||
return (bool)debug;
|
||||
}
|
@ -129,8 +129,6 @@ __attribute__((visibility("default")))
|
||||
+ (JNIEnv*)getJNIEnvUncached;
|
||||
+ (void)detachCurrentThread;
|
||||
+ (void)setAppkitThreadGroup:(jobject)group;
|
||||
+ (void)setAWTEmbedded:(BOOL)embedded;
|
||||
+ (BOOL)isAWTEmbedded;
|
||||
|
||||
//Wrappers for the corresponding JNFRunLoop methods with a check for main thread
|
||||
+ (void)performOnMainThreadWaiting:(BOOL)wait block:(void (^)())block;
|
||||
|
@ -34,7 +34,6 @@
|
||||
JavaVM *jvm = NULL;
|
||||
static JNIEnv *appKitEnv = NULL;
|
||||
static jobject appkitThreadGroup = NULL;
|
||||
static BOOL awtEmbedded = NO;
|
||||
|
||||
static inline void attachCurrentThread(void** env) {
|
||||
if ([NSThread isMainThread]) {
|
||||
@ -88,14 +87,6 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)setAWTEmbedded:(BOOL)embedded {
|
||||
awtEmbedded = embedded;
|
||||
}
|
||||
|
||||
+ (BOOL)isAWTEmbedded {
|
||||
return awtEmbedded;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
@ -1816,20 +1816,48 @@ ShowSplashScreen()
|
||||
const char *jar_name = getenv(SPLASH_JAR_ENV_ENTRY);
|
||||
const char *file_name = getenv(SPLASH_FILE_ENV_ENTRY);
|
||||
int data_size;
|
||||
void *image_data;
|
||||
void *image_data = NULL;
|
||||
float scale_factor = 1;
|
||||
char *scaled_splash_name = NULL;
|
||||
|
||||
if (file_name == NULL){
|
||||
return;
|
||||
}
|
||||
|
||||
scaled_splash_name = DoSplashGetScaledImageName(
|
||||
jar_name, file_name, &scale_factor);
|
||||
if (jar_name) {
|
||||
image_data = JLI_JarUnpackFile(jar_name, file_name, &data_size);
|
||||
|
||||
if (scaled_splash_name) {
|
||||
image_data = JLI_JarUnpackFile(
|
||||
jar_name, scaled_splash_name, &data_size);
|
||||
}
|
||||
|
||||
if (!image_data) {
|
||||
scale_factor = 1;
|
||||
image_data = JLI_JarUnpackFile(
|
||||
jar_name, file_name, &data_size);
|
||||
}
|
||||
if (image_data) {
|
||||
DoSplashInit();
|
||||
DoSplashSetScaleFactor(scale_factor);
|
||||
DoSplashLoadMemory(image_data, data_size);
|
||||
JLI_MemFree(image_data);
|
||||
}
|
||||
} else if (file_name) {
|
||||
DoSplashInit();
|
||||
DoSplashLoadFile(file_name);
|
||||
} else {
|
||||
return;
|
||||
DoSplashInit();
|
||||
if (scaled_splash_name) {
|
||||
DoSplashSetScaleFactor(scale_factor);
|
||||
DoSplashLoadFile(scaled_splash_name);
|
||||
} else {
|
||||
DoSplashLoadFile(file_name);
|
||||
}
|
||||
}
|
||||
|
||||
if (scaled_splash_name) {
|
||||
JLI_MemFree(scaled_splash_name);
|
||||
}
|
||||
|
||||
DoSplashSetFileJarName(file_name, jar_name);
|
||||
|
||||
/*
|
||||
|
@ -29,3 +29,6 @@ int DoSplashLoadFile(const char* filename);
|
||||
void DoSplashInit(void);
|
||||
void DoSplashClose(void);
|
||||
void DoSplashSetFileJarName(const char* fileName, const char* jarName);
|
||||
void DoSplashSetScaleFactor(float scaleFactor);
|
||||
char* DoSplashGetScaledImageName(const char* jarName, const char* fileName,
|
||||
float* scaleFactor);
|
||||
|
@ -37,6 +37,9 @@ typedef void (*SplashInit_t)(void);
|
||||
typedef void (*SplashClose_t)(void);
|
||||
typedef void (*SplashSetFileJarName_t)(const char* fileName,
|
||||
const char* jarName);
|
||||
typedef void (*SplashSetScaleFactor_t)(float scaleFactor);
|
||||
typedef char* (*SplashGetScaledImageName_t)(const char* fileName,
|
||||
const char* jarName, float* scaleFactor);
|
||||
|
||||
/*
|
||||
* This macro invokes a function from the shared lib.
|
||||
@ -58,11 +61,11 @@ typedef void (*SplashSetFileJarName_t)(const char* fileName,
|
||||
#define INVOKEV(name) _INVOKE(name, ,;)
|
||||
|
||||
int DoSplashLoadMemory(void* pdata, int size) {
|
||||
INVOKE(SplashLoadMemory,0)(pdata, size);
|
||||
INVOKE(SplashLoadMemory, NULL)(pdata, size);
|
||||
}
|
||||
|
||||
int DoSplashLoadFile(const char* filename) {
|
||||
INVOKE(SplashLoadFile,0)(filename);
|
||||
INVOKE(SplashLoadFile, NULL)(filename);
|
||||
}
|
||||
|
||||
void DoSplashInit(void) {
|
||||
@ -76,3 +79,12 @@ void DoSplashClose(void) {
|
||||
void DoSplashSetFileJarName(const char* fileName, const char* jarName) {
|
||||
INVOKEV(SplashSetFileJarName)(fileName, jarName);
|
||||
}
|
||||
|
||||
void DoSplashSetScaleFactor(float scaleFactor) {
|
||||
INVOKEV(SplashSetScaleFactor)(scaleFactor);
|
||||
}
|
||||
|
||||
char* DoSplashGetScaledImageName(const char* fileName, const char* jarName,
|
||||
float* scaleFactor) {
|
||||
INVOKE(SplashGetScaledImageName, NULL)(fileName, jarName, scaleFactor);
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 com.sun.beans.introspect;
|
||||
|
||||
import com.sun.beans.util.Cache;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static sun.reflect.misc.ReflectUtil.checkPackageAccess;
|
||||
|
||||
public final class ClassInfo {
|
||||
private static final ClassInfo DEFAULT = new ClassInfo(null);
|
||||
private static final Cache<Class<?>,ClassInfo> CACHE
|
||||
= new Cache<Class<?>,ClassInfo>(Cache.Kind.SOFT, Cache.Kind.SOFT) {
|
||||
@Override
|
||||
public ClassInfo create(Class<?> type) {
|
||||
return new ClassInfo(type);
|
||||
}
|
||||
};
|
||||
|
||||
public static ClassInfo get(Class<?> type) {
|
||||
if (type == null) {
|
||||
return DEFAULT;
|
||||
}
|
||||
try {
|
||||
checkPackageAccess(type);
|
||||
return CACHE.get(type);
|
||||
} catch (SecurityException exception) {
|
||||
return DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
private final Object mutex = new Object();
|
||||
private final Class<?> type;
|
||||
private List<Method> methods;
|
||||
private Map<String,PropertyInfo> properties;
|
||||
private Map<String,EventSetInfo> eventSets;
|
||||
|
||||
private ClassInfo(Class<?> type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public List<Method> getMethods() {
|
||||
if (this.methods == null) {
|
||||
synchronized (this.mutex) {
|
||||
if (this.methods == null) {
|
||||
this.methods = MethodInfo.get(this.type);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.methods;
|
||||
}
|
||||
|
||||
public Map<String,PropertyInfo> getProperties() {
|
||||
if (this.properties == null) {
|
||||
synchronized (this.mutex) {
|
||||
if (this.properties == null) {
|
||||
this.properties = PropertyInfo.get(this.type);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.properties;
|
||||
}
|
||||
|
||||
public Map<String,EventSetInfo> getEventSets() {
|
||||
if (this.eventSets == null) {
|
||||
synchronized (this.mutex) {
|
||||
if (this.eventSets == null) {
|
||||
this.eventSets = EventSetInfo.get(this.type);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.eventSets;
|
||||
}
|
||||
}
|
145
jdk/src/share/classes/com/sun/beans/introspect/EventSetInfo.java
Normal file
145
jdk/src/share/classes/com/sun/beans/introspect/EventSetInfo.java
Normal file
@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 com.sun.beans.introspect;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Collections;
|
||||
import java.util.EventListener;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TooManyListenersException;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public final class EventSetInfo {
|
||||
private MethodInfo add;
|
||||
private MethodInfo remove;
|
||||
private MethodInfo get;
|
||||
|
||||
private EventSetInfo() {
|
||||
}
|
||||
|
||||
private boolean initialize() {
|
||||
if ((this.add == null) || (this.remove == null) || (this.remove.type != this.add.type)) {
|
||||
return false;
|
||||
}
|
||||
if ((this.get != null) && (this.get.type != this.add.type)) {
|
||||
this.get = null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Class<?> getListenerType() {
|
||||
return this.add.type;
|
||||
}
|
||||
|
||||
public Method getAddMethod() {
|
||||
return this.add.method;
|
||||
}
|
||||
|
||||
public Method getRemoveMethod() {
|
||||
return this.remove.method;
|
||||
}
|
||||
|
||||
public Method getGetMethod() {
|
||||
return (this.get == null) ? null : this.get.method;
|
||||
}
|
||||
|
||||
public boolean isUnicast() {
|
||||
// if the adder method throws the TooManyListenersException
|
||||
// then it is an Unicast event source
|
||||
return this.add.isThrow(TooManyListenersException.class);
|
||||
}
|
||||
|
||||
private static MethodInfo getInfo(MethodInfo info, Method method, int prefix, int postfix) {
|
||||
Class<?> type = (postfix > 0)
|
||||
? MethodInfo.resolve(method, method.getGenericReturnType()).getComponentType()
|
||||
: MethodInfo.resolve(method, method.getGenericParameterTypes()[0]);
|
||||
|
||||
if ((type != null) && EventListener.class.isAssignableFrom(type)) {
|
||||
String name = method.getName();
|
||||
if (prefix + postfix < name.length()) {
|
||||
if (type.getName().endsWith(name.substring(prefix, name.length() - postfix))) {
|
||||
if ((info == null) || info.type.isAssignableFrom(type)) {
|
||||
return new MethodInfo(method, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
private static EventSetInfo getInfo(Map<String,EventSetInfo> map, String key) {
|
||||
EventSetInfo info = map.get(key);
|
||||
if (info == null) {
|
||||
info = new EventSetInfo();
|
||||
map.put(key, info);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
public static Map<String,EventSetInfo> get(Class<?> type) {
|
||||
List<Method> methods = ClassInfo.get(type).getMethods();
|
||||
if (methods.isEmpty()) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
Map<String,EventSetInfo> map = new TreeMap<>();
|
||||
for (Method method : ClassInfo.get(type).getMethods()) {
|
||||
if (!Modifier.isStatic(method.getModifiers())) {
|
||||
Class<?> returnType = method.getReturnType();
|
||||
String name = method.getName();
|
||||
switch (method.getParameterCount()) {
|
||||
case 1:
|
||||
if ((returnType == void.class) && name.endsWith("Listener")) {
|
||||
if (name.startsWith("add")) {
|
||||
EventSetInfo info = getInfo(map, name.substring(3, name.length() - 8));
|
||||
info.add = getInfo(info.add, method, 3, 0);
|
||||
} else if (name.startsWith("remove")) {
|
||||
EventSetInfo info = getInfo(map, name.substring(6, name.length() - 8));
|
||||
info.remove = getInfo(info.remove, method, 6, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0:
|
||||
if (returnType.isArray() && name.startsWith("get") && name.endsWith("Listeners")) {
|
||||
EventSetInfo info = getInfo(map, name.substring(3, name.length() - 9));
|
||||
info.get = getInfo(info.get, method, 3, 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Iterator<EventSetInfo> iterator = map.values().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
if (!iterator.next().initialize()) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
return !map.isEmpty()
|
||||
? Collections.unmodifiableMap(map)
|
||||
: Collections.emptyMap();
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 com.sun.beans.introspect;
|
||||
|
||||
import com.sun.beans.TypeResolver;
|
||||
import com.sun.beans.finder.MethodFinder;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
final class MethodInfo {
|
||||
final Method method;
|
||||
final Class<?> type;
|
||||
|
||||
MethodInfo(Method method, Class<?> type) {
|
||||
this.method = method;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
MethodInfo(Method method, Type type) {
|
||||
this.method = method;
|
||||
this.type = resolve(method, type);
|
||||
}
|
||||
|
||||
boolean isThrow(Class<?> exception) {
|
||||
for (Class<?> type : this.method.getExceptionTypes()) {
|
||||
if (type == exception) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static Class<?> resolve(Method method, Type type) {
|
||||
return TypeResolver.erase(TypeResolver.resolveInClass(method.getDeclaringClass(), type));
|
||||
}
|
||||
|
||||
static List<Method> get(Class<?> type) {
|
||||
List<Method> list = null;
|
||||
if (type != null) {
|
||||
boolean inaccessible = !Modifier.isPublic(type.getModifiers());
|
||||
for (Method method : type.getMethods()) {
|
||||
if (method.getDeclaringClass().equals(type)) {
|
||||
if (inaccessible) {
|
||||
try {
|
||||
method = MethodFinder.findAccessibleMethod(method);
|
||||
if (!method.getDeclaringClass().isInterface()) {
|
||||
method = null; // ignore methods from superclasses
|
||||
}
|
||||
} catch (NoSuchMethodException exception) {
|
||||
// commented out because of 6976577
|
||||
// method = null; // ignore inaccessible methods
|
||||
}
|
||||
}
|
||||
if (method != null) {
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
list.add(method);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return (list != null)
|
||||
? Collections.unmodifiableList(list)
|
||||
: Collections.emptyList();
|
||||
}
|
||||
}
|
301
jdk/src/share/classes/com/sun/beans/introspect/PropertyInfo.java
Normal file
301
jdk/src/share/classes/com/sun/beans/introspect/PropertyInfo.java
Normal file
@ -0,0 +1,301 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 com.sun.beans.introspect;
|
||||
|
||||
import java.beans.BeanProperty;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import static com.sun.beans.finder.ClassFinder.findClass;
|
||||
|
||||
public final class PropertyInfo {
|
||||
public enum Name {bound, expert, hidden, preferred, visualUpdate, description, enumerationValues}
|
||||
|
||||
private static final String VETO_EXCEPTION_NAME = "java.beans.PropertyVetoException";
|
||||
private static final Class<?> VETO_EXCEPTION;
|
||||
|
||||
static {
|
||||
Class<?> type;
|
||||
try {
|
||||
type = Class.forName(VETO_EXCEPTION_NAME);
|
||||
} catch (Exception exception) {
|
||||
type = null;
|
||||
}
|
||||
VETO_EXCEPTION = type;
|
||||
}
|
||||
|
||||
private Class<?> type;
|
||||
private MethodInfo read;
|
||||
private MethodInfo write;
|
||||
private PropertyInfo indexed;
|
||||
private List<MethodInfo> readList;
|
||||
private List<MethodInfo> writeList;
|
||||
private Map<Name,Object> map;
|
||||
|
||||
private PropertyInfo() {
|
||||
}
|
||||
|
||||
private boolean initialize() {
|
||||
if (this.read != null) {
|
||||
this.type = this.read.type;
|
||||
}
|
||||
if (this.readList != null) {
|
||||
for (MethodInfo info : this.readList) {
|
||||
if ((this.read == null) || this.read.type.isAssignableFrom(info.type)) {
|
||||
this.read = info;
|
||||
this.type = info.type;
|
||||
}
|
||||
}
|
||||
this.readList = null;
|
||||
}
|
||||
if (this.writeList != null) {
|
||||
for (MethodInfo info : this.writeList) {
|
||||
if (this.type == null) {
|
||||
this.write = info;
|
||||
this.type = info.type;
|
||||
} else if (this.type.isAssignableFrom(info.type)) {
|
||||
if ((this.write == null) || this.write.type.isAssignableFrom(info.type)) {
|
||||
this.write = info;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.writeList = null;
|
||||
}
|
||||
if (this.indexed != null) {
|
||||
if ((this.type != null) && !this.type.isArray()) {
|
||||
this.indexed = null; // property type is not an array
|
||||
} else if (!this.indexed.initialize()) {
|
||||
this.indexed = null; // cannot initialize indexed methods
|
||||
} else if ((this.type != null) && (this.indexed.type != this.type.getComponentType())) {
|
||||
this.indexed = null; // different property types
|
||||
} else {
|
||||
this.map = this.indexed.map;
|
||||
this.indexed.map = null;
|
||||
}
|
||||
}
|
||||
if ((this.type == null) && (this.indexed == null)) {
|
||||
return false;
|
||||
}
|
||||
initialize(this.write);
|
||||
initialize(this.read);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void initialize(MethodInfo info) {
|
||||
if (info != null) {
|
||||
BeanProperty annotation = info.method.getAnnotation(BeanProperty.class);
|
||||
if (annotation != null) {
|
||||
if (!annotation.bound()) {
|
||||
put(Name.bound, Boolean.FALSE);
|
||||
}
|
||||
put(Name.expert, annotation.expert());
|
||||
put(Name.hidden, annotation.hidden());
|
||||
put(Name.preferred, annotation.preferred());
|
||||
put(Name.visualUpdate, annotation.visualUpdate());
|
||||
put(Name.description, annotation.description());
|
||||
String[] values = annotation.enumerationValues();
|
||||
if (0 < values.length) {
|
||||
try {
|
||||
Object[] array = new Object[3 * values.length];
|
||||
int index = 0;
|
||||
for (String value : values) {
|
||||
Class<?> type = info.method.getDeclaringClass();
|
||||
String name = value;
|
||||
int pos = value.lastIndexOf('.');
|
||||
if (pos > 0) {
|
||||
name = value.substring(0, pos);
|
||||
if (name.indexOf('.') < 0) {
|
||||
String pkg = type.getName();
|
||||
name = pkg.substring(0, 1 + Math.max(
|
||||
pkg.lastIndexOf('.'),
|
||||
pkg.lastIndexOf('$'))) + name;
|
||||
}
|
||||
type = findClass(name);
|
||||
name = value.substring(pos + 1);
|
||||
}
|
||||
Field field = type.getField(name);
|
||||
if (Modifier.isStatic(field.getModifiers()) && info.type.isAssignableFrom(field.getType())) {
|
||||
array[index++] = name;
|
||||
array[index++] = field.get(null);
|
||||
array[index++] = value;
|
||||
}
|
||||
}
|
||||
if (index == array.length) {
|
||||
put(Name.enumerationValues, array);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
ignored.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Class<?> getPropertyType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public Method getReadMethod() {
|
||||
return (this.read == null) ? null : this.read.method;
|
||||
}
|
||||
|
||||
public Method getWriteMethod() {
|
||||
return (this.write == null) ? null : this.write.method;
|
||||
}
|
||||
|
||||
public PropertyInfo getIndexed() {
|
||||
return this.indexed;
|
||||
}
|
||||
|
||||
public boolean isConstrained() {
|
||||
if (this.write != null) {
|
||||
if (VETO_EXCEPTION == null) {
|
||||
for (Class<?> type : this.write.method.getExceptionTypes()) {
|
||||
if (type.getName().equals(VETO_EXCEPTION_NAME)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (this.write.isThrow(VETO_EXCEPTION)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return (this.indexed != null) && this.indexed.isConstrained();
|
||||
}
|
||||
|
||||
public boolean is(Name name) {
|
||||
Object value = get(name);
|
||||
return (value instanceof Boolean)
|
||||
? (Boolean) value
|
||||
: Name.bound.equals(name);
|
||||
}
|
||||
|
||||
public Object get(Name name) {
|
||||
return this.map == null ? null : this.map.get(name);
|
||||
}
|
||||
|
||||
private void put(Name name, boolean value) {
|
||||
if (value) {
|
||||
put(name, Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
private void put(Name name, String value) {
|
||||
if (0 < value.length()) {
|
||||
put(name, (Object) value);
|
||||
}
|
||||
}
|
||||
|
||||
private void put(Name name, Object value) {
|
||||
if (this.map == null) {
|
||||
this.map = new EnumMap<>(Name.class);
|
||||
}
|
||||
this.map.put(name, value);
|
||||
}
|
||||
|
||||
private static List<MethodInfo> add(List<MethodInfo> list, Method method, Type type) {
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
list.add(new MethodInfo(method, type));
|
||||
return list;
|
||||
}
|
||||
|
||||
private static boolean isPrefix(String name, String prefix) {
|
||||
return name.length() > prefix.length() && name.startsWith(prefix);
|
||||
}
|
||||
|
||||
private static PropertyInfo getInfo(Map<String,PropertyInfo> map, String key, boolean indexed) {
|
||||
PropertyInfo info = map.get(key);
|
||||
if (info == null) {
|
||||
info = new PropertyInfo();
|
||||
map.put(key, info);
|
||||
}
|
||||
if (!indexed) {
|
||||
return info;
|
||||
}
|
||||
if (info.indexed == null) {
|
||||
info.indexed = new PropertyInfo();
|
||||
}
|
||||
return info.indexed;
|
||||
}
|
||||
|
||||
public static Map<String,PropertyInfo> get(Class<?> type) {
|
||||
List<Method> methods = ClassInfo.get(type).getMethods();
|
||||
if (methods.isEmpty()) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
Map<String,PropertyInfo> map = new TreeMap<>();
|
||||
for (Method method : methods) {
|
||||
if (!Modifier.isStatic(method.getModifiers())) {
|
||||
Class<?> returnType = method.getReturnType();
|
||||
String name = method.getName();
|
||||
switch (method.getParameterCount()) {
|
||||
case 0:
|
||||
if (returnType.equals(boolean.class) && isPrefix(name, "is")) {
|
||||
PropertyInfo info = getInfo(map, name.substring(2), false);
|
||||
info.read = new MethodInfo(method, boolean.class);
|
||||
} else if (!returnType.equals(void.class) && isPrefix(name, "get")) {
|
||||
PropertyInfo info = getInfo(map, name.substring(3), false);
|
||||
info.readList = add(info.readList, method, method.getGenericReturnType());
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (returnType.equals(void.class) && isPrefix(name, "set")) {
|
||||
PropertyInfo info = getInfo(map, name.substring(3), false);
|
||||
info.writeList = add(info.writeList, method, method.getGenericParameterTypes()[0]);
|
||||
} else if (!returnType.equals(void.class) && method.getParameterTypes()[0].equals(int.class) && isPrefix(name, "get")) {
|
||||
PropertyInfo info = getInfo(map, name.substring(3), true);
|
||||
info.readList = add(info.readList, method, method.getGenericReturnType());
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (returnType.equals(void.class) && method.getParameterTypes()[0].equals(int.class) && isPrefix(name, "set")) {
|
||||
PropertyInfo info = getInfo(map, name.substring(3), true);
|
||||
info.writeList = add(info.writeList, method, method.getGenericParameterTypes()[1]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Iterator<PropertyInfo> iterator = map.values().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
if (!iterator.next().initialize()) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
return !map.isEmpty()
|
||||
? Collections.unmodifiableMap(map)
|
||||
: Collections.emptyMap();
|
||||
}
|
||||
}
|
@ -82,14 +82,14 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
||||
private String renameFileErrorTitle = null;
|
||||
private String renameFileErrorText = null;
|
||||
|
||||
private JComboBox filterComboBox;
|
||||
private JComboBox<FileFilter> filterComboBox;
|
||||
private FilterComboBoxModel filterComboBoxModel;
|
||||
|
||||
// From Motif
|
||||
|
||||
private JPanel rightPanel;
|
||||
private JList directoryList;
|
||||
private JList fileList;
|
||||
private JList<File> directoryList;
|
||||
private JList<File> fileList;
|
||||
|
||||
private JLabel pathField;
|
||||
private JTextField fileNameTextField;
|
||||
@ -116,7 +116,7 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
||||
private int pathLabelMnemonic = 0;
|
||||
private int filterLabelMnemonic = 0;
|
||||
|
||||
private JComboBox directoryComboBox;
|
||||
private JComboBox<File> directoryComboBox;
|
||||
private DirectoryComboBoxModel directoryComboBoxModel;
|
||||
private Action directoryComboBoxAction = new DirectoryComboBoxAction();
|
||||
private JPanel bottomButtonPanel;
|
||||
@ -153,7 +153,7 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
||||
}
|
||||
|
||||
int mode = fc.getFileSelectionMode();
|
||||
JList list = mode == JFileChooser.DIRECTORIES_ONLY ?
|
||||
JList<File> list = mode == JFileChooser.DIRECTORIES_ONLY ?
|
||||
directoryList : fileList;
|
||||
Object[] files = list.getSelectedValues();
|
||||
int len = files.length;
|
||||
@ -369,8 +369,8 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
||||
}
|
||||
|
||||
class DoubleClickListener extends MouseAdapter {
|
||||
JList list;
|
||||
public DoubleClickListener(JList list) {
|
||||
JList<?> list;
|
||||
public DoubleClickListener(JList<?> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@ -413,7 +413,7 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
||||
}
|
||||
}
|
||||
|
||||
protected MouseListener createDoubleClickListener(JFileChooser fc, JList list) {
|
||||
protected MouseListener createDoubleClickListener(JFileChooser fc, JList<?> list) {
|
||||
return new DoubleClickListener(list);
|
||||
}
|
||||
|
||||
@ -423,7 +423,7 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
if (!e.getValueIsAdjusting()) {
|
||||
JFileChooser chooser = getFileChooser();
|
||||
JList list = (JList) e.getSource();
|
||||
JList<?> list = (JList) e.getSource();
|
||||
|
||||
if (chooser.isMultiSelectionEnabled()) {
|
||||
File[] files = null;
|
||||
@ -554,7 +554,7 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
||||
0, 0) {
|
||||
public void layoutContainer(Container target) {
|
||||
super.layoutContainer(target);
|
||||
JComboBox comboBox = directoryComboBox;
|
||||
JComboBox<?> comboBox = directoryComboBox;
|
||||
if (comboBox.getWidth() > target.getWidth()) {
|
||||
comboBox.setBounds(0, comboBox.getY(), target.getWidth(),
|
||||
comboBox.getHeight());
|
||||
@ -565,7 +565,7 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
||||
comboBoxPanel.setName("GTKFileChooser.directoryComboBoxPanel");
|
||||
// CurrentDir ComboBox
|
||||
directoryComboBoxModel = createDirectoryComboBoxModel(fc);
|
||||
directoryComboBox = new JComboBox(directoryComboBoxModel);
|
||||
directoryComboBox = new JComboBox<>(directoryComboBoxModel);
|
||||
directoryComboBox.setName("GTKFileChooser.directoryComboBox");
|
||||
directoryComboBox.putClientProperty( "JComboBox.lightweightKeyboardNavigation", "Lightweight" );
|
||||
directoryComboBox.addActionListener(directoryComboBoxAction);
|
||||
@ -710,7 +710,7 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
||||
|
||||
filterComboBoxModel = createFilterComboBoxModel();
|
||||
fc.addPropertyChangeListener(filterComboBoxModel);
|
||||
filterComboBox = new JComboBox(filterComboBoxModel);
|
||||
filterComboBox = new JComboBox<>(filterComboBoxModel);
|
||||
filterComboBox.setRenderer(createFilterComboBoxRenderer());
|
||||
filterLabel.setLabelFor(filterComboBox);
|
||||
|
||||
@ -851,7 +851,7 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
||||
}
|
||||
|
||||
protected JScrollPane createFilesList() {
|
||||
fileList = new JList();
|
||||
fileList = new JList<>();
|
||||
fileList.setName("GTKFileChooser.fileList");
|
||||
fileList.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, filesLabelText);
|
||||
|
||||
@ -877,7 +877,7 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
||||
}
|
||||
|
||||
protected JScrollPane createDirectoryList() {
|
||||
directoryList = new JList();
|
||||
directoryList = new JList<>();
|
||||
directoryList.setName("GTKFileChooser.directoryList");
|
||||
directoryList.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, foldersLabelText);
|
||||
align(directoryList);
|
||||
@ -930,7 +930,7 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial") // Superclass is not serializable across versions
|
||||
protected class GTKDirectoryListModel extends AbstractListModel implements ListDataListener {
|
||||
protected class GTKDirectoryListModel extends AbstractListModel<File> implements ListDataListener {
|
||||
File curDir;
|
||||
public GTKDirectoryListModel() {
|
||||
getModel().addListDataListener(this);
|
||||
@ -941,7 +941,8 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
||||
return getModel().getDirectories().size() + 1;
|
||||
}
|
||||
|
||||
public Object getElementAt(int index) {
|
||||
@Override
|
||||
public File getElementAt(int index) {
|
||||
return index > 0 ? getModel().getDirectories().elementAt(index - 1):
|
||||
curDir;
|
||||
}
|
||||
@ -974,7 +975,7 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial") // Superclass is not serializable across versions
|
||||
protected class GTKFileListModel extends AbstractListModel implements ListDataListener {
|
||||
protected class GTKFileListModel extends AbstractListModel<File> implements ListDataListener {
|
||||
public GTKFileListModel() {
|
||||
getModel().addListDataListener(this);
|
||||
}
|
||||
@ -991,7 +992,8 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
||||
return getModel().getFiles().indexOf(o);
|
||||
}
|
||||
|
||||
public Object getElementAt(int index) {
|
||||
@Override
|
||||
public File getElementAt(int index) {
|
||||
return getModel().getFiles().elementAt(index);
|
||||
}
|
||||
|
||||
@ -1019,7 +1021,7 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
||||
|
||||
@SuppressWarnings("serial") // Superclass is not serializable across versions
|
||||
protected class FileCellRenderer extends DefaultListCellRenderer {
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index,
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index,
|
||||
boolean isSelected, boolean cellHasFocus) {
|
||||
|
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
@ -1033,7 +1035,7 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
||||
|
||||
@SuppressWarnings("serial") // Superclass is not serializable across versions
|
||||
protected class DirectoryCellRenderer extends DefaultListCellRenderer {
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index,
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index,
|
||||
boolean isSelected, boolean cellHasFocus) {
|
||||
|
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
@ -1095,7 +1097,7 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
||||
* Data model for a type-face selection combo-box.
|
||||
*/
|
||||
@SuppressWarnings("serial") // Superclass is not serializable across versions
|
||||
protected class DirectoryComboBoxModel extends AbstractListModel implements ComboBoxModel {
|
||||
protected class DirectoryComboBoxModel extends AbstractListModel<File> implements ComboBoxModel<File> {
|
||||
Vector<File> directories = new Vector<File>();
|
||||
File selectedDirectory = null;
|
||||
JFileChooser chooser = getFileChooser();
|
||||
@ -1163,7 +1165,8 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
||||
return directories.size();
|
||||
}
|
||||
|
||||
public Object getElementAt(int index) {
|
||||
@Override
|
||||
public File getElementAt(int index) {
|
||||
return directories.elementAt(index);
|
||||
}
|
||||
}
|
||||
@ -1314,7 +1317,7 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Component getListCellRendererComponent(JList list, Object value,
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value,
|
||||
int index, boolean isSelected,
|
||||
boolean cellHasFocus) {
|
||||
|
||||
@ -1345,8 +1348,8 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
||||
* Data model for filter combo-box.
|
||||
*/
|
||||
@SuppressWarnings("serial") // JDK implementation class
|
||||
protected class FilterComboBoxModel extends AbstractListModel
|
||||
implements ComboBoxModel, PropertyChangeListener {
|
||||
protected class FilterComboBoxModel extends AbstractListModel<FileFilter>
|
||||
implements ComboBoxModel<FileFilter>, PropertyChangeListener {
|
||||
protected FileFilter[] filters;
|
||||
|
||||
protected FilterComboBoxModel() {
|
||||
@ -1400,7 +1403,8 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
||||
}
|
||||
}
|
||||
|
||||
public Object getElementAt(int index) {
|
||||
@Override
|
||||
public FileFilter getElementAt(int index) {
|
||||
if (index > getSize() - 1) {
|
||||
// This shouldn't happen. Try to recover gracefully.
|
||||
return getFileChooser().getFileFilter();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2014, 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
|
||||
@ -151,7 +151,7 @@ class GTKIconFactory {
|
||||
|
||||
private static class DelegatingIcon extends SynthIcon implements
|
||||
UIResource {
|
||||
private static final Class[] PARAM_TYPES = new Class[] {
|
||||
private static final Class<?>[] PARAM_TYPES = new Class<?>[] {
|
||||
SynthContext.class, Graphics.class, int.class,
|
||||
int.class, int.class, int.class, int.class
|
||||
};
|
||||
@ -190,7 +190,7 @@ class GTKIconFactory {
|
||||
return (Method)method;
|
||||
}
|
||||
|
||||
protected Class[] getMethodParamTypes() {
|
||||
protected Class<?>[] getMethodParamTypes() {
|
||||
return PARAM_TYPES;
|
||||
}
|
||||
|
||||
@ -262,7 +262,7 @@ class GTKIconFactory {
|
||||
// we create a unique icon per ToolBar and lookup the style for the
|
||||
// HandleBox.
|
||||
private static class ToolBarHandleIcon extends DelegatingIcon {
|
||||
private static final Class[] PARAM_TYPES = new Class[] {
|
||||
private static final Class<?>[] PARAM_TYPES = new Class<?>[] {
|
||||
SynthContext.class, Graphics.class, int.class,
|
||||
int.class, int.class, int.class, int.class, Orientation.class,
|
||||
};
|
||||
@ -273,7 +273,7 @@ class GTKIconFactory {
|
||||
super(TOOL_BAR_HANDLE_ICON);
|
||||
}
|
||||
|
||||
protected Class[] getMethodParamTypes() {
|
||||
protected Class<?>[] getMethodParamTypes() {
|
||||
return PARAM_TYPES;
|
||||
}
|
||||
|
||||
@ -323,7 +323,7 @@ class GTKIconFactory {
|
||||
}
|
||||
|
||||
private static class MenuArrowIcon extends DelegatingIcon {
|
||||
private static final Class[] PARAM_TYPES = new Class[] {
|
||||
private static final Class<?>[] PARAM_TYPES = new Class<?>[] {
|
||||
SynthContext.class, Graphics.class, int.class,
|
||||
int.class, int.class, int.class, int.class, ArrowType.class,
|
||||
};
|
||||
@ -332,7 +332,7 @@ class GTKIconFactory {
|
||||
super(MENU_ARROW_ICON);
|
||||
}
|
||||
|
||||
protected Class[] getMethodParamTypes() {
|
||||
protected Class<?>[] getMethodParamTypes() {
|
||||
return PARAM_TYPES;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2014, 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
|
||||
@ -1086,13 +1086,13 @@ class GTKStyle extends SynthStyle implements GTKConstants {
|
||||
|
||||
public Object createValue(UIDefaults table) {
|
||||
try {
|
||||
Class c = Class.forName(className, true,Thread.currentThread().
|
||||
getContextClassLoader());
|
||||
Class<?> c = Class.forName(className, true,Thread.currentThread().
|
||||
getContextClassLoader());
|
||||
|
||||
if (methodName == null) {
|
||||
return c.newInstance();
|
||||
}
|
||||
Method m = c.getMethod(methodName, (Class[])null);
|
||||
Method m = c.getMethod(methodName, (Class<?>[])null);
|
||||
|
||||
return m.invoke(c, (Object[])null);
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2014, 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
|
||||
@ -764,7 +764,7 @@ class Metacity implements SynthConstants {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
Map gm = getFrameGeometry();
|
||||
Map<String, Object> gm = getFrameGeometry();
|
||||
|
||||
int w = titlePane.getWidth();
|
||||
int h = titlePane.getHeight();
|
||||
@ -828,11 +828,11 @@ class Metacity implements SynthConstants {
|
||||
}
|
||||
} // end TitlePaneLayout
|
||||
|
||||
protected Map getFrameGeometry() {
|
||||
protected Map<String, Object> getFrameGeometry() {
|
||||
return frameGeometry;
|
||||
}
|
||||
|
||||
protected void setFrameGeometry(JComponent titlePane, Map gm) {
|
||||
protected void setFrameGeometry(JComponent titlePane, Map<String, Object> gm) {
|
||||
this.frameGeometry = gm;
|
||||
if (getInt("top_height") == 0 && titlePane != null) {
|
||||
gm.put("top_height", Integer.valueOf(titlePane.getHeight()));
|
||||
@ -1501,7 +1501,7 @@ class Metacity implements SynthConstants {
|
||||
"name", getStringAttr(frame, "style")
|
||||
});
|
||||
if (frame_style != null) {
|
||||
Map gm = frameGeometries.get(getStringAttr(frame_style, "geometry"));
|
||||
Map<String, Object> gm = frameGeometries.get(getStringAttr(frame_style, "geometry"));
|
||||
|
||||
setFrameGeometry(titlePane, gm);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2014, 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
|
||||
@ -34,7 +34,7 @@ import javax.swing.plaf.ColorUIResource;
|
||||
*/
|
||||
class XColors {
|
||||
|
||||
private static class XColor implements Comparable {
|
||||
private static class XColor implements Comparable<XColor> {
|
||||
String name;
|
||||
|
||||
int red;
|
||||
@ -52,10 +52,8 @@ class XColors {
|
||||
return new ColorUIResource(red, green, blue);
|
||||
}
|
||||
|
||||
public int compareTo(Object o) {
|
||||
XColor other = (XColor)o;
|
||||
|
||||
return name.compareTo(other.name);
|
||||
public int compareTo(XColor o) {
|
||||
return name.compareTo(o.name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ public class MotifComboBoxUI extends BasicComboBoxUI implements Serializable {
|
||||
@SuppressWarnings("serial") // Superclass is not serializable across versions
|
||||
protected class MotifComboPopup extends BasicComboPopup {
|
||||
|
||||
public MotifComboPopup( JComboBox comboBox ) {
|
||||
public MotifComboPopup( JComboBox<Object> comboBox ) {
|
||||
super( comboBox );
|
||||
}
|
||||
|
||||
@ -177,7 +177,7 @@ public class MotifComboBoxUI extends BasicComboBoxUI implements Serializable {
|
||||
}
|
||||
|
||||
public void paintCurrentValue(Graphics g,Rectangle bounds,boolean hasFocus) {
|
||||
ListCellRenderer renderer = comboBox.getRenderer();
|
||||
ListCellRenderer<Object> renderer = comboBox.getRenderer();
|
||||
Component c;
|
||||
Dimension d;
|
||||
c = renderer.getListCellRendererComponent(listBox, comboBox.getSelectedItem(), -1, false, false);
|
||||
|
@ -342,7 +342,7 @@ public class MotifFileChooserUI extends BasicFileChooserUI {
|
||||
leftPanel.add(l);
|
||||
|
||||
@SuppressWarnings("serial") // anonymous class
|
||||
JComboBox tmp2 = new JComboBox<FileFilter>() {
|
||||
JComboBox<FileFilter> tmp2 = new JComboBox<FileFilter>() {
|
||||
public Dimension getMaximumSize() {
|
||||
Dimension d = super.getMaximumSize();
|
||||
d.height = getPreferredSize().height;
|
||||
@ -655,7 +655,7 @@ public class MotifFileChooserUI extends BasicFileChooserUI {
|
||||
|
||||
@SuppressWarnings("serial") // Superclass is not serializable across versions
|
||||
protected class FileCellRenderer extends DefaultListCellRenderer {
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index,
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index,
|
||||
boolean isSelected, boolean cellHasFocus) {
|
||||
|
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
@ -667,7 +667,7 @@ public class MotifFileChooserUI extends BasicFileChooserUI {
|
||||
|
||||
@SuppressWarnings("serial") // Superclass is not serializable across versions
|
||||
protected class DirectoryCellRenderer extends DefaultListCellRenderer {
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index,
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index,
|
||||
boolean isSelected, boolean cellHasFocus) {
|
||||
|
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
@ -778,7 +778,7 @@ public class MotifFileChooserUI extends BasicFileChooserUI {
|
||||
*/
|
||||
@SuppressWarnings("serial") // Superclass is not serializable across versions
|
||||
public class FilterComboBoxRenderer extends DefaultListCellRenderer {
|
||||
public Component getListCellRendererComponent(JList list,
|
||||
public Component getListCellRendererComponent(JList<?> list,
|
||||
Object value, int index, boolean isSelected,
|
||||
boolean cellHasFocus) {
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2014, 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
|
||||
@ -130,11 +130,14 @@ class AnimationController implements ActionListener, PropertyChangeListener {
|
||||
//one second seems plausible value
|
||||
duration = 1000;
|
||||
} else {
|
||||
duration = XPStyle.getXP().getThemeTransitionDuration(
|
||||
c, part,
|
||||
normalizeState(oldState),
|
||||
normalizeState(newState),
|
||||
Prop.TRANSITIONDURATIONS);
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
duration = (xp != null)
|
||||
? xp.getThemeTransitionDuration(
|
||||
c, part,
|
||||
normalizeState(oldState),
|
||||
normalizeState(newState),
|
||||
Prop.TRANSITIONDURATIONS)
|
||||
: 1000;
|
||||
}
|
||||
controller.startAnimation(c, part, oldState, newState, duration);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2014, 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
|
||||
@ -102,7 +102,7 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
|
||||
private static void updateAllUIs() {
|
||||
// Check if the current UI is WindowsLookAndfeel and flush the XP style map.
|
||||
// Note: Change the package test if this class is moved to a different package.
|
||||
Class uiClass = UIManager.getLookAndFeel().getClass();
|
||||
Class<?> uiClass = UIManager.getLookAndFeel().getClass();
|
||||
if (uiClass.getPackage().equals(DesktopProperty.class.getPackage())) {
|
||||
XPStyle.invalidateStyle();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2014, 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
|
||||
@ -446,7 +446,7 @@ class TMSchema {
|
||||
initStates();
|
||||
}
|
||||
|
||||
Enum[] states = stateMap.get(part);
|
||||
Enum<?>[] states = stateMap.get(part);
|
||||
if (states != null) {
|
||||
for (int i = 0; i < states.length; i++) {
|
||||
if (state == states[i]) {
|
||||
@ -504,10 +504,10 @@ class TMSchema {
|
||||
|
||||
TRANSITIONDURATIONS(Integer.class, 6000);
|
||||
|
||||
private final Class type;
|
||||
private final Class<?> type;
|
||||
private final int value;
|
||||
|
||||
private Prop(Class type, int value) {
|
||||
private Prop(Class<?> type, int value) {
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2014, 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
|
||||
@ -37,6 +37,7 @@ import java.awt.*;
|
||||
import static com.sun.java.swing.plaf.windows.TMSchema.Part;
|
||||
import static com.sun.java.swing.plaf.windows.TMSchema.State;
|
||||
import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
|
||||
|
||||
import sun.swing.DefaultLookup;
|
||||
import sun.swing.StringUIClientPropertyKey;
|
||||
|
||||
@ -60,7 +61,7 @@ public class WindowsComboBoxUI extends BasicComboBoxUI {
|
||||
private static final MouseListener rolloverListener =
|
||||
new MouseAdapter() {
|
||||
private void handleRollover(MouseEvent e, boolean isRollover) {
|
||||
JComboBox comboBox = getComboBox(e);
|
||||
JComboBox<?> comboBox = getComboBox(e);
|
||||
WindowsComboBoxUI comboBoxUI = getWindowsComboBoxUI(e);
|
||||
if (comboBox == null || comboBoxUI == null) {
|
||||
return;
|
||||
@ -88,9 +89,9 @@ public class WindowsComboBoxUI extends BasicComboBoxUI {
|
||||
handleRollover(e, false);
|
||||
}
|
||||
|
||||
private JComboBox getComboBox(MouseEvent event) {
|
||||
private JComboBox<?> getComboBox(MouseEvent event) {
|
||||
Object source = event.getSource();
|
||||
JComboBox rv = null;
|
||||
JComboBox<?> rv = null;
|
||||
if (source instanceof JComboBox) {
|
||||
rv = (JComboBox) source;
|
||||
} else if (source instanceof XPComboBoxButton) {
|
||||
@ -101,7 +102,7 @@ public class WindowsComboBoxUI extends BasicComboBoxUI {
|
||||
}
|
||||
|
||||
private WindowsComboBoxUI getWindowsComboBoxUI(MouseEvent event) {
|
||||
JComboBox comboBox = getComboBox(event);
|
||||
JComboBox<?> comboBox = getComboBox(event);
|
||||
WindowsComboBoxUI rv = null;
|
||||
if (comboBox != null
|
||||
&& comboBox.getUI() instanceof WindowsComboBoxUI) {
|
||||
@ -122,7 +123,7 @@ public class WindowsComboBoxUI extends BasicComboBoxUI {
|
||||
&& (source = e.getSource()) instanceof JComboBox
|
||||
&& ((JComboBox) source).getUI() instanceof
|
||||
WindowsComboBoxUI) {
|
||||
JComboBox comboBox = (JComboBox) source;
|
||||
JComboBox<?> comboBox = (JComboBox) source;
|
||||
WindowsComboBoxUI comboBoxUI = (WindowsComboBoxUI) comboBox.getUI();
|
||||
if (comboBoxUI.arrowButton instanceof XPComboBoxButton) {
|
||||
((XPComboBoxButton) comboBoxUI.arrowButton).setPart(
|
||||
@ -231,6 +232,9 @@ public class WindowsComboBoxUI extends BasicComboBoxUI {
|
||||
|
||||
private void paintXPComboBoxBackground(Graphics g, JComponent c) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp == null) {
|
||||
return;
|
||||
}
|
||||
State state = getXPComboBoxState(c);
|
||||
Skin skin = null;
|
||||
if (! comboBox.isEditable()
|
||||
@ -273,7 +277,7 @@ public class WindowsComboBoxUI extends BasicComboBoxUI {
|
||||
// color for currentValue is the same as for any other item
|
||||
|
||||
// mostly copied from javax.swing.plaf.basic.BasicComboBoxUI.paintCurrentValue
|
||||
ListCellRenderer renderer = comboBox.getRenderer();
|
||||
ListCellRenderer<Object> renderer = comboBox.getRenderer();
|
||||
Component c;
|
||||
if ( hasFocus && !isPopupVisible(comboBox) ) {
|
||||
c = renderer.getListCellRendererComponent(
|
||||
@ -384,7 +388,7 @@ public class WindowsComboBoxUI extends BasicComboBoxUI {
|
||||
* @since 1.6
|
||||
*/
|
||||
@Override
|
||||
protected ListCellRenderer createRenderer() {
|
||||
protected ListCellRenderer<Object> createRenderer() {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null && xp.isSkinDefined(comboBox, Part.CP_READONLY)) {
|
||||
return new WindowsComboBoxRenderer();
|
||||
@ -400,8 +404,9 @@ public class WindowsComboBoxUI extends BasicComboBoxUI {
|
||||
* @return a button which represents the popup control
|
||||
*/
|
||||
protected JButton createArrowButton() {
|
||||
if (XPStyle.getXP() != null) {
|
||||
return new XPComboBoxButton();
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
return new XPComboBoxButton(xp);
|
||||
} else {
|
||||
return super.createArrowButton();
|
||||
}
|
||||
@ -409,9 +414,9 @@ public class WindowsComboBoxUI extends BasicComboBoxUI {
|
||||
|
||||
@SuppressWarnings("serial") // Superclass is not serializable across versions
|
||||
private class XPComboBoxButton extends XPStyle.GlyphButton {
|
||||
public XPComboBoxButton() {
|
||||
public XPComboBoxButton(XPStyle xp) {
|
||||
super(null,
|
||||
(! XPStyle.getXP().isSkinDefined(comboBox, Part.CP_DROPDOWNBUTTONRIGHT))
|
||||
(! xp.isSkinDefined(comboBox, Part.CP_DROPDOWNBUTTONRIGHT))
|
||||
? Part.CP_DROPDOWNBUTTON
|
||||
: (comboBox.getComponentOrientation() == ComponentOrientation.RIGHT_TO_LEFT)
|
||||
? Part.CP_DROPDOWNBUTTONLEFT
|
||||
@ -424,10 +429,11 @@ public class WindowsComboBoxUI extends BasicComboBoxUI {
|
||||
protected State getState() {
|
||||
State rv;
|
||||
rv = super.getState();
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (rv != State.DISABLED
|
||||
&& comboBox != null && ! comboBox.isEditable()
|
||||
&& XPStyle.getXP().isSkinDefined(comboBox,
|
||||
Part.CP_DROPDOWNBUTTONRIGHT)) {
|
||||
&& xp != null && xp.isSkinDefined(comboBox,
|
||||
Part.CP_DROPDOWNBUTTONRIGHT)) {
|
||||
/*
|
||||
* for non editable ComboBoxes Vista seems to have the
|
||||
* same glyph for all non DISABLED states
|
||||
@ -463,7 +469,7 @@ public class WindowsComboBoxUI extends BasicComboBoxUI {
|
||||
@SuppressWarnings("serial") // Superclass is not serializable across versions
|
||||
protected class WindowsComboPopup extends BasicComboPopup {
|
||||
|
||||
public WindowsComboPopup( JComboBox cBox ) {
|
||||
public WindowsComboPopup( JComboBox<Object> cBox ) {
|
||||
super( cBox );
|
||||
}
|
||||
|
||||
@ -523,7 +529,7 @@ public class WindowsComboBoxUI extends BasicComboBoxUI {
|
||||
*/
|
||||
@Override
|
||||
public Component getListCellRendererComponent(
|
||||
JList list,
|
||||
JList<?> list,
|
||||
Object value,
|
||||
int index,
|
||||
boolean isSelected,
|
||||
|
@ -191,7 +191,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
|
||||
return WindowsFileChooserUI.this.getNewFolderAction();
|
||||
}
|
||||
|
||||
public MouseListener createDoubleClickListener(JList list) {
|
||||
public MouseListener createDoubleClickListener(JList<?> list) {
|
||||
return WindowsFileChooserUI.this.createDoubleClickListener(getFileChooser(),
|
||||
list);
|
||||
}
|
||||
@ -994,7 +994,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
|
||||
@SuppressWarnings("serial") // Superclass is not serializable across versions
|
||||
class DirectoryComboBoxRenderer extends DefaultListCellRenderer {
|
||||
IndentIcon ii = new IndentIcon();
|
||||
public Component getListCellRendererComponent(JList list, Object value,
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value,
|
||||
int index, boolean isSelected,
|
||||
boolean cellHasFocus) {
|
||||
|
||||
@ -1184,7 +1184,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
|
||||
*/
|
||||
@SuppressWarnings("serial") // Superclass is not serializable across versions
|
||||
public class FilterComboBoxRenderer extends DefaultListCellRenderer {
|
||||
public Component getListCellRendererComponent(JList list,
|
||||
public Component getListCellRendererComponent(JList<?> list,
|
||||
Object value, int index, boolean isSelected,
|
||||
boolean cellHasFocus) {
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2014, 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
|
||||
@ -125,6 +125,9 @@ public class WindowsGraphicsUtils {
|
||||
static void paintXPText(AbstractButton b, Part part, State state,
|
||||
Graphics g, int x, int y, String text, int mnemIndex) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp == null) {
|
||||
return;
|
||||
}
|
||||
Color textColor = b.getForeground();
|
||||
|
||||
if (textColor instanceof UIResource) {
|
||||
|
@ -623,8 +623,8 @@ public class WindowsIconFactory implements Serializable
|
||||
@SuppressWarnings("serial") // Same-version serialization only
|
||||
private static class MenuArrowIcon implements Icon, UIResource, Serializable {
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
if (WindowsMenuItemUI.isVistaPainting()) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (WindowsMenuItemUI.isVistaPainting(xp)) {
|
||||
State state = State.NORMAL;
|
||||
if (c instanceof JMenuItem) {
|
||||
state = ((JMenuItem) c).getModel().isEnabled()
|
||||
@ -657,16 +657,18 @@ public class WindowsIconFactory implements Serializable
|
||||
}
|
||||
}
|
||||
public int getIconWidth() {
|
||||
if (WindowsMenuItemUI.isVistaPainting()) {
|
||||
Skin skin = XPStyle.getXP().getSkin(null, Part.MP_POPUPSUBMENU);
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (WindowsMenuItemUI.isVistaPainting(xp)) {
|
||||
Skin skin = xp.getSkin(null, Part.MP_POPUPSUBMENU);
|
||||
return skin.getWidth();
|
||||
} else {
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
public int getIconHeight() {
|
||||
if (WindowsMenuItemUI.isVistaPainting()) {
|
||||
Skin skin = XPStyle.getXP().getSkin(null, Part.MP_POPUPSUBMENU);
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (WindowsMenuItemUI.isVistaPainting(xp)) {
|
||||
Skin skin = xp.getSkin(null, Part.MP_POPUPSUBMENU);
|
||||
return skin.getHeight();
|
||||
} else {
|
||||
return 8;
|
||||
@ -692,7 +694,8 @@ public class WindowsIconFactory implements Serializable
|
||||
}
|
||||
|
||||
static int getIconWidth() {
|
||||
return XPStyle.getXP().getSkin(null, Part.MP_POPUPCHECK).getWidth()
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
return ((xp != null) ? xp.getSkin(null, Part.MP_POPUPCHECK).getWidth() : 16)
|
||||
+ 2 * OFFSET;
|
||||
}
|
||||
|
||||
@ -756,12 +759,17 @@ public class WindowsIconFactory implements Serializable
|
||||
Icon icon = getIcon();
|
||||
int height = 0;
|
||||
if (icon != null) {
|
||||
height = icon.getIconHeight() + 2 * OFFSET;
|
||||
height = icon.getIconHeight();
|
||||
} else {
|
||||
Skin skin =
|
||||
XPStyle.getXP().getSkin(null, Part.MP_POPUPCHECK);
|
||||
height = skin.getHeight() + 2 * OFFSET;
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
Skin skin = xp.getSkin(null, Part.MP_POPUPCHECK);
|
||||
height = skin.getHeight();
|
||||
} else {
|
||||
height = 16;
|
||||
}
|
||||
}
|
||||
height += 2 * OFFSET;
|
||||
return height;
|
||||
}
|
||||
|
||||
@ -809,14 +817,16 @@ public class WindowsIconFactory implements Serializable
|
||||
? State.BULLETDISABLED
|
||||
: State.CHECKMARKDISABLED;
|
||||
}
|
||||
Skin skin;
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
skin = xp.getSkin(c, backgroundPart);
|
||||
skin.paintSkin(g, x, y,
|
||||
getIconWidth(), getIconHeight(), backgroundState);
|
||||
if (icon == null) {
|
||||
skin = xp.getSkin(c, part);
|
||||
skin.paintSkin(g, x + OFFSET, y + OFFSET, state);
|
||||
if (xp != null) {
|
||||
Skin skin;
|
||||
skin = xp.getSkin(c, backgroundPart);
|
||||
skin.paintSkin(g, x, y,
|
||||
getIconWidth(), getIconHeight(), backgroundState);
|
||||
if (icon == null) {
|
||||
skin = xp.getSkin(c, part);
|
||||
skin.paintSkin(g, x + OFFSET, y + OFFSET, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2014, 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
|
||||
@ -86,14 +86,15 @@ public class WindowsInternalFrameTitlePane extends BasicInternalFrameTitlePane {
|
||||
}
|
||||
} else {
|
||||
buttonWidth += 2;
|
||||
selectedTitleGradientColor =
|
||||
UIManager.getColor("InternalFrame.activeTitleGradient");
|
||||
notSelectedTitleGradientColor =
|
||||
UIManager.getColor("InternalFrame.inactiveTitleGradient");
|
||||
Color activeBorderColor =
|
||||
UIManager.getColor("InternalFrame.activeBorderColor");
|
||||
setBorder(BorderFactory.createLineBorder(activeBorderColor, 1));
|
||||
}
|
||||
// JDK-8039383: initialize these colors because getXP() may return null when theme is changed
|
||||
selectedTitleGradientColor =
|
||||
UIManager.getColor("InternalFrame.activeTitleGradient");
|
||||
notSelectedTitleGradientColor =
|
||||
UIManager.getColor("InternalFrame.inactiveTitleGradient");
|
||||
}
|
||||
|
||||
protected void uninstallListeners() {
|
||||
|
@ -2326,8 +2326,9 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
|
||||
}
|
||||
|
||||
public Object getXPValue(UIDefaults table) {
|
||||
Border xpBorder = XPStyle.getXP().getBorder(null, (Part)xpValue);
|
||||
if (extraMargin != null) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
Border xpBorder = xp != null ? xp.getBorder(null, (Part)xpValue) : null;
|
||||
if (xpBorder != null && extraMargin != null) {
|
||||
return new BorderUIResource.
|
||||
CompoundBorderUIResource(xpBorder, extraMargin);
|
||||
} else {
|
||||
@ -2343,7 +2344,8 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
|
||||
|
||||
public Object getXPValue(UIDefaults table) {
|
||||
XPColorValueKey key = (XPColorValueKey)xpValue;
|
||||
return XPStyle.getXP().getColor(key.skin, key.prop, null);
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
return xp != null ? xp.getColor(key.skin, key.prop, null) : null;
|
||||
}
|
||||
|
||||
private static class XPColorValueKey {
|
||||
|
@ -156,8 +156,8 @@ public class WindowsMenuBarUI extends BasicMenuBarUI
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g, JComponent c) {
|
||||
if (WindowsMenuItemUI.isVistaPainting()) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (WindowsMenuItemUI.isVistaPainting(xp)) {
|
||||
Skin skin;
|
||||
skin = xp.getSkin(c, Part.MP_BARBACKGROUND);
|
||||
int width = c.getWidth();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2014, 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
|
||||
@ -108,8 +108,9 @@ public class WindowsMenuItemUI extends BasicMenuItemUI {
|
||||
|
||||
static void paintBackground(WindowsMenuItemUIAccessor menuItemUI,
|
||||
Graphics g, JMenuItem menuItem, Color bgColor) {
|
||||
assert isVistaPainting();
|
||||
if (isVistaPainting()) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
assert isVistaPainting(xp);
|
||||
if (isVistaPainting(xp)) {
|
||||
int menuWidth = menuItem.getWidth();
|
||||
int menuHeight = menuItem.getHeight();
|
||||
if (menuItem.isOpaque()) {
|
||||
@ -118,7 +119,6 @@ public class WindowsMenuItemUI extends BasicMenuItemUI {
|
||||
g.fillRect(0,0, menuWidth, menuHeight);
|
||||
g.setColor(oldColor);
|
||||
}
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
Part part = menuItemUI.getPart(menuItem);
|
||||
Skin skin = xp.getSkin(menuItem, part);
|
||||
skin.paintSkin(g, 0 , 0,
|
||||
@ -170,8 +170,11 @@ public class WindowsMenuItemUI extends BasicMenuItemUI {
|
||||
* is it possible that in some theme some Vista parts are not defined while
|
||||
* others are?
|
||||
*/
|
||||
static boolean isVistaPainting() {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
static boolean isVistaPainting(final XPStyle xp) {
|
||||
return xp != null && xp.isSkinDefined(null, Part.MP_POPUPITEM);
|
||||
}
|
||||
|
||||
static boolean isVistaPainting() {
|
||||
return isVistaPainting(XPStyle.getXP());
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2004, 2014, 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,8 @@ public class WindowsPopupMenuSeparatorUI extends BasicPopupMenuSeparatorUI {
|
||||
|
||||
public void paint(Graphics g, JComponent c) {
|
||||
Dimension s = c.getSize();
|
||||
if (WindowsMenuItemUI.isVistaPainting()) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (WindowsMenuItemUI.isVistaPainting(xp)) {
|
||||
int x = 1;
|
||||
Component parent = c.getParent();
|
||||
if (parent instanceof JComponent) {
|
||||
@ -67,7 +68,7 @@ public class WindowsPopupMenuSeparatorUI extends BasicPopupMenuSeparatorUI {
|
||||
x += WindowsPopupMenuUI.getGutterWidth();
|
||||
}
|
||||
}
|
||||
Skin skin = XPStyle.getXP().getSkin(c, Part.MP_POPUPSEPARATOR);
|
||||
Skin skin = xp.getSkin(c, Part.MP_POPUPSEPARATOR);
|
||||
int skinHeight = skin.getHeight();
|
||||
int y = (s.height - skinHeight) / 2;
|
||||
skin.paintSkin(g, x, y, s.width - x - 1, skinHeight, State.NORMAL);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2014, 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
|
||||
@ -194,8 +194,8 @@ public class WindowsPopupMenuUI extends BasicPopupMenuUI {
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g, JComponent c) {
|
||||
if (WindowsMenuItemUI.isVistaPainting()) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (WindowsMenuItemUI.isVistaPainting(xp)) {
|
||||
Skin skin = xp.getSkin(c, Part.MP_POPUPBACKGROUND);
|
||||
skin.paintSkin(g, 0, 0, c.getWidth(),c.getHeight(), State.NORMAL);
|
||||
int textOffset = getTextOffset(c);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2014, 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
|
||||
@ -322,8 +322,9 @@ public class WindowsProgressBarUI extends BasicProgressBarUI
|
||||
private Rectangle getFullChunkBounds(Rectangle box) {
|
||||
boolean vertical = (progressBar.getOrientation() == JProgressBar.VERTICAL);
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
int gap = xp.getInt(progressBar, Part.PP_PROGRESS, null,
|
||||
Prop.PROGRESSSPACESIZE, 0);
|
||||
int gap = (xp != null) ? xp.getInt(progressBar, Part.PP_PROGRESS,
|
||||
null, Prop.PROGRESSSPACESIZE, 0)
|
||||
: 0;
|
||||
|
||||
if (!vertical) {
|
||||
int chunksize = box.width+gap;
|
||||
@ -338,6 +339,9 @@ public class WindowsProgressBarUI extends BasicProgressBarUI
|
||||
boolean vertical,
|
||||
int bgwidth, int bgheight) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// create a new graphics to keep drawing surface state
|
||||
Graphics2D gfx = (Graphics2D)g.create();
|
||||
@ -396,6 +400,9 @@ public class WindowsProgressBarUI extends BasicProgressBarUI
|
||||
private void paintXPBackground(Graphics g, boolean vertical,
|
||||
int barRectWidth, int barRectHeight) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp == null) {
|
||||
return;
|
||||
}
|
||||
Part part = vertical ? Part.PP_BARVERT : Part.PP_BAR;
|
||||
Skin skin = xp.getSkin(progressBar, part);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2014, 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
|
||||
@ -215,7 +215,6 @@ public class WindowsSliderUI extends BasicSliderUI
|
||||
}
|
||||
|
||||
private Part getXPThumbPart() {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
Part part;
|
||||
boolean vertical = (slider.getOrientation() == JSlider.VERTICAL);
|
||||
boolean leftToRight = slider.getComponentOrientation().isLeftToRight();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2014, 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
|
||||
@ -63,6 +63,9 @@ public class WindowsSpinnerUI extends BasicSpinnerUI {
|
||||
|
||||
private void paintXPBackground(Graphics g, JComponent c) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp == null) {
|
||||
return;
|
||||
}
|
||||
Skin skin = xp.getSkin(c, Part.EP_EDIT);
|
||||
State state = getXPState(c);
|
||||
skin.paintSkin(g, 0, 0, c.getWidth(), c.getHeight(), state);
|
||||
|
@ -91,9 +91,10 @@ public class WindowsTableHeaderUI extends BasicTableHeaderUI {
|
||||
this.column = column;
|
||||
this.hasRollover = (column == getRolloverColumn());
|
||||
if (skin == null) {
|
||||
skin = XPStyle.getXP().getSkin(header, Part.HP_HEADERITEM);
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
skin = (xp != null) ? xp.getSkin(header, Part.HP_HEADERITEM) : null;
|
||||
}
|
||||
Insets margins = skin.getContentMargin();
|
||||
Insets margins = (skin != null) ? skin.getContentMargin() : null;
|
||||
Border border = null;
|
||||
int contentTop = 0;
|
||||
int contentLeft = 0;
|
||||
|
@ -115,7 +115,7 @@ class XPStyle {
|
||||
}
|
||||
}
|
||||
}
|
||||
return xp;
|
||||
return ThemeReader.isXPStyleEnabled() ? xp : null;
|
||||
}
|
||||
|
||||
static boolean isVista() {
|
||||
@ -180,9 +180,10 @@ class XPStyle {
|
||||
* should probably be cached there instead of here.
|
||||
*/
|
||||
Dimension getDimension(Component c, Part part, State state, Prop prop) {
|
||||
return ThemeReader.getPosition(part.getControlName(c), part.getValue(),
|
||||
State.getValue(part, state),
|
||||
prop.getValue());
|
||||
Dimension d = ThemeReader.getPosition(part.getControlName(c), part.getValue(),
|
||||
State.getValue(part, state),
|
||||
prop.getValue());
|
||||
return (d != null) ? d : new Dimension();
|
||||
}
|
||||
|
||||
/** Get a named <code>Point</code> (e.g. a location or an offset) value
|
||||
@ -199,11 +200,7 @@ class XPStyle {
|
||||
Dimension d = ThemeReader.getPosition(part.getControlName(c), part.getValue(),
|
||||
State.getValue(part, state),
|
||||
prop.getValue());
|
||||
if (d != null) {
|
||||
return new Point(d.width, d.height);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return (d != null) ? new Point(d.width, d.height) : new Point();
|
||||
}
|
||||
|
||||
/** Get a named <code>Insets</code> value from the current style
|
||||
@ -217,9 +214,10 @@ class XPStyle {
|
||||
* The return value is already cached in those places.
|
||||
*/
|
||||
Insets getMargin(Component c, Part part, State state, Prop prop) {
|
||||
return ThemeReader.getThemeMargins(part.getControlName(c), part.getValue(),
|
||||
State.getValue(part, state),
|
||||
prop.getValue());
|
||||
Insets insets = ThemeReader.getThemeMargins(part.getControlName(c), part.getValue(),
|
||||
State.getValue(part, state),
|
||||
prop.getValue());
|
||||
return (insets != null) ? insets : new Insets(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -349,7 +347,7 @@ class XPStyle {
|
||||
// special casing for comboboxes.
|
||||
// there may be more special cases in the future
|
||||
if(c instanceof JComboBox) {
|
||||
JComboBox cb = (JComboBox)c;
|
||||
JComboBox<?> cb = (JComboBox)c;
|
||||
// note. in the future this should be replaced with a call
|
||||
// to BasicLookAndFeel.getUIOfType()
|
||||
if(cb.getUI() instanceof WindowsComboBoxUI) {
|
||||
@ -509,16 +507,17 @@ class XPStyle {
|
||||
int boundingWidth = 100;
|
||||
int boundingHeight = 100;
|
||||
|
||||
return ThemeReader.getThemeBackgroundContentMargins(
|
||||
Insets insets = ThemeReader.getThemeBackgroundContentMargins(
|
||||
part.getControlName(null), part.getValue(),
|
||||
0, boundingWidth, boundingHeight);
|
||||
return (insets != null) ? insets : new Insets(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
private int getWidth(State state) {
|
||||
if (size == null) {
|
||||
size = getPartSize(part, state);
|
||||
}
|
||||
return size.width;
|
||||
return (size != null) ? size.width : 0;
|
||||
}
|
||||
|
||||
int getWidth() {
|
||||
@ -529,7 +528,7 @@ class XPStyle {
|
||||
if (size == null) {
|
||||
size = getPartSize(part, state);
|
||||
}
|
||||
return size.height;
|
||||
return (size != null) ? size.height : 0;
|
||||
}
|
||||
|
||||
int getHeight() {
|
||||
@ -586,6 +585,9 @@ class XPStyle {
|
||||
* @param state which state to paint
|
||||
*/
|
||||
void paintSkin(Graphics g, int dx, int dy, int dw, int dh, State state) {
|
||||
if (XPStyle.getXP() == null) {
|
||||
return;
|
||||
}
|
||||
if (ThemeReader.isGetThemeTransitionDurationDefined()
|
||||
&& component instanceof JComponent
|
||||
&& SwingUtilities.getAncestorOfClass(CellRendererPane.class,
|
||||
@ -611,6 +613,9 @@ class XPStyle {
|
||||
* @param state which state to paint
|
||||
*/
|
||||
void paintSkinRaw(Graphics g, int dx, int dy, int dw, int dh, State state) {
|
||||
if (XPStyle.getXP() == null) {
|
||||
return;
|
||||
}
|
||||
skinPainter.paint(null, g, dx, dy, dw, dh, this, state);
|
||||
}
|
||||
|
||||
@ -629,6 +634,9 @@ class XPStyle {
|
||||
*/
|
||||
void paintSkin(Graphics g, int dx, int dy, int dw, int dh, State state,
|
||||
boolean borderFill) {
|
||||
if (XPStyle.getXP() == null) {
|
||||
return;
|
||||
}
|
||||
if(borderFill && "borderfill".equals(getTypeEnumName(component, part,
|
||||
state, Prop.BGTYPE))) {
|
||||
return;
|
||||
@ -684,7 +692,7 @@ class XPStyle {
|
||||
|
||||
public GlyphButton(Component parent, Part part) {
|
||||
XPStyle xp = getXP();
|
||||
skin = xp.getSkin(parent, part);
|
||||
skin = xp != null ? xp.getSkin(parent, part) : null;
|
||||
setBorder(null);
|
||||
setContentAreaFilled(false);
|
||||
setMinimumSize(new Dimension(5, 5));
|
||||
@ -709,13 +717,16 @@ class XPStyle {
|
||||
}
|
||||
|
||||
public void paintComponent(Graphics g) {
|
||||
if (XPStyle.getXP() == null || skin == null) {
|
||||
return;
|
||||
}
|
||||
Dimension d = getSize();
|
||||
skin.paintSkin(g, 0, 0, d.width, d.height, getState());
|
||||
}
|
||||
|
||||
public void setPart(Component parent, Part part) {
|
||||
XPStyle xp = getXP();
|
||||
skin = xp.getSkin(parent, part);
|
||||
skin = xp != null ? xp.getSkin(parent, part) : null;
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2014, 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
|
||||
@ -34,22 +34,14 @@ import javax.security.auth.Subject;
|
||||
|
||||
import javax.management.remote.SubjectDelegationPermission;
|
||||
|
||||
import com.sun.jmx.remote.util.CacheMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.*;
|
||||
|
||||
public class SubjectDelegator {
|
||||
private static final int PRINCIPALS_CACHE_SIZE = 10;
|
||||
private static final int ACC_CACHE_SIZE = 10;
|
||||
|
||||
private CacheMap<Subject, Principal[]> principalsCache;
|
||||
private CacheMap<Subject, AccessControlContext> accCache;
|
||||
|
||||
/* Return the AccessControlContext appropriate to execute an
|
||||
operation on behalf of the delegatedSubject. If the
|
||||
authenticatedAccessControlContext does not have permission to
|
||||
delegate to that subject, throw SecurityException. */
|
||||
public synchronized AccessControlContext
|
||||
public AccessControlContext
|
||||
delegatedContext(AccessControlContext authenticatedACC,
|
||||
Subject delegatedSubject,
|
||||
boolean removeCallerContext)
|
||||
@ -58,56 +50,14 @@ public class SubjectDelegator {
|
||||
if (System.getSecurityManager() != null && authenticatedACC == null) {
|
||||
throw new SecurityException("Illegal AccessControlContext: null");
|
||||
}
|
||||
if (principalsCache == null || accCache == null) {
|
||||
principalsCache =
|
||||
new CacheMap<>(PRINCIPALS_CACHE_SIZE);
|
||||
accCache =
|
||||
new CacheMap<>(ACC_CACHE_SIZE);
|
||||
}
|
||||
|
||||
// Retrieve the principals for the given
|
||||
// delegated subject from the cache
|
||||
//
|
||||
Principal[] delegatedPrincipals = principalsCache.get(delegatedSubject);
|
||||
|
||||
// Convert the set of principals stored in the
|
||||
// delegated subject into an array of principals
|
||||
// and store it in the cache
|
||||
//
|
||||
if (delegatedPrincipals == null) {
|
||||
delegatedPrincipals =
|
||||
delegatedSubject.getPrincipals().toArray(new Principal[0]);
|
||||
principalsCache.put(delegatedSubject, delegatedPrincipals);
|
||||
}
|
||||
|
||||
// Retrieve the access control context for the
|
||||
// given delegated subject from the cache
|
||||
//
|
||||
AccessControlContext delegatedACC = accCache.get(delegatedSubject);
|
||||
|
||||
// Build the access control context to be used
|
||||
// when executing code as the delegated subject
|
||||
// and store it in the cache
|
||||
//
|
||||
if (delegatedACC == null) {
|
||||
if (removeCallerContext) {
|
||||
delegatedACC =
|
||||
JMXSubjectDomainCombiner.getDomainCombinerContext(
|
||||
delegatedSubject);
|
||||
} else {
|
||||
delegatedACC =
|
||||
JMXSubjectDomainCombiner.getContext(delegatedSubject);
|
||||
}
|
||||
accCache.put(delegatedSubject, delegatedACC);
|
||||
}
|
||||
|
||||
// Check if the subject delegation permission allows the
|
||||
// authenticated subject to assume the identity of each
|
||||
// principal in the delegated subject
|
||||
//
|
||||
final Principal[] dp = delegatedPrincipals;
|
||||
final Collection<Permission> permissions = new ArrayList<>(dp.length);
|
||||
for(Principal p : dp) {
|
||||
Collection<Principal> ps = getSubjectPrincipals(delegatedSubject);
|
||||
final Collection<Permission> permissions = new ArrayList<>(ps.size());
|
||||
for(Principal p : ps) {
|
||||
final String pname = p.getClass().getName() + "." + p.getName();
|
||||
permissions.add(new SubjectDelegationPermission(pname));
|
||||
}
|
||||
@ -122,7 +72,15 @@ public class SubjectDelegator {
|
||||
};
|
||||
AccessController.doPrivileged(action, authenticatedACC);
|
||||
|
||||
return delegatedACC;
|
||||
return getDelegatedAcc(delegatedSubject, removeCallerContext);
|
||||
}
|
||||
|
||||
private AccessControlContext getDelegatedAcc(Subject delegatedSubject, boolean removeCallerContext) {
|
||||
if (removeCallerContext) {
|
||||
return JMXSubjectDomainCombiner.getDomainCombinerContext(delegatedSubject);
|
||||
} else {
|
||||
return JMXSubjectDomainCombiner.getContext(delegatedSubject);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -137,11 +95,9 @@ public class SubjectDelegator {
|
||||
public static synchronized boolean
|
||||
checkRemoveCallerContext(Subject subject) {
|
||||
try {
|
||||
final Principal[] dp =
|
||||
subject.getPrincipals().toArray(new Principal[0]);
|
||||
for (int i = 0 ; i < dp.length ; i++) {
|
||||
for (Principal p : getSubjectPrincipals(subject)) {
|
||||
final String pname =
|
||||
dp[i].getClass().getName() + "." + dp[i].getName();
|
||||
p.getClass().getName() + "." + p.getName();
|
||||
final Permission sdp =
|
||||
new SubjectDelegationPermission(pname);
|
||||
AccessController.checkPermission(sdp);
|
||||
@ -151,4 +107,19 @@ public class SubjectDelegator {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the {@linkplain Subject} principals
|
||||
* @param subject The subject
|
||||
* @return If the {@code Subject} is immutable it will return the principals directly.
|
||||
* If the {@code Subject} is mutable it will create an unmodifiable copy.
|
||||
*/
|
||||
private static Collection<Principal> getSubjectPrincipals(Subject subject) {
|
||||
if (subject.isReadOnly()) {
|
||||
return subject.getPrincipals();
|
||||
}
|
||||
|
||||
List<Principal> principals = Arrays.asList(subject.getPrincipals().toArray(new Principal[0]));
|
||||
return Collections.unmodifiableList(principals);
|
||||
}
|
||||
}
|
||||
|
@ -1,121 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2006, 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 com.sun.jmx.remote.util;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import com.sun.jmx.mbeanserver.Util;
|
||||
|
||||
/**
|
||||
* <p>Like WeakHashMap, except that the keys of the <em>n</em> most
|
||||
* recently-accessed entries are kept as {@link SoftReference soft
|
||||
* references}. Accessing an element means creating it, or retrieving
|
||||
* it with {@link #get(Object) get}. Because these entries are kept
|
||||
* with soft references, they will tend to remain even if their keys
|
||||
* are not referenced elsewhere. But if memory is short, they will
|
||||
* be removed.</p>
|
||||
*/
|
||||
public class CacheMap<K, V> extends WeakHashMap<K, V> {
|
||||
/**
|
||||
* <p>Create a <code>CacheMap</code> that can keep up to
|
||||
* <code>nSoftReferences</code> as soft references.</p>
|
||||
*
|
||||
* @param nSoftReferences Maximum number of keys to keep as soft
|
||||
* references. Access times for {@link #get(Object) get} and
|
||||
* {@link #put(Object, Object) put} have a component that scales
|
||||
* linearly with <code>nSoftReferences</code>, so this value
|
||||
* should not be too great.
|
||||
*
|
||||
* @throws IllegalArgumentException if
|
||||
* <code>nSoftReferences</code> is negative.
|
||||
*/
|
||||
public CacheMap(int nSoftReferences) {
|
||||
if (nSoftReferences < 0) {
|
||||
throw new IllegalArgumentException("nSoftReferences = " +
|
||||
nSoftReferences);
|
||||
}
|
||||
this.nSoftReferences = nSoftReferences;
|
||||
}
|
||||
|
||||
public V put(K key, V value) {
|
||||
cache(key);
|
||||
return super.put(key, value);
|
||||
}
|
||||
|
||||
public V get(Object key) {
|
||||
cache(Util.<K>cast(key));
|
||||
return super.get(key);
|
||||
}
|
||||
|
||||
/* We don't override remove(Object) or try to do something with
|
||||
the map's iterators to detect removal. So we may keep useless
|
||||
entries in the soft reference list for keys that have since
|
||||
been removed. The assumption is that entries are added to the
|
||||
cache but never removed. But the behavior is not wrong if
|
||||
they are in fact removed -- the caching is just less
|
||||
performant. */
|
||||
|
||||
private void cache(K key) {
|
||||
Iterator<SoftReference<K>> it = cache.iterator();
|
||||
while (it.hasNext()) {
|
||||
SoftReference<K> sref = it.next();
|
||||
K key1 = sref.get();
|
||||
if (key1 == null)
|
||||
it.remove();
|
||||
else if (key.equals(key1)) {
|
||||
// Move this element to the head of the LRU list
|
||||
it.remove();
|
||||
cache.add(0, sref);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int size = cache.size();
|
||||
if (size == nSoftReferences) {
|
||||
if (size == 0)
|
||||
return; // degenerate case, equivalent to WeakHashMap
|
||||
it.remove();
|
||||
}
|
||||
|
||||
cache.add(0, new SoftReference<K>(key));
|
||||
}
|
||||
|
||||
/* List of soft references for the most-recently referenced keys.
|
||||
The list is in most-recently-used order, i.e. the first element
|
||||
is the most-recently referenced key. There are never more than
|
||||
nSoftReferences elements of this list.
|
||||
|
||||
If we didn't care about J2SE 1.3 compatibility, we could use
|
||||
LinkedHashSet in conjunction with a subclass of SoftReference
|
||||
whose equals and hashCode reflect the referent. */
|
||||
private final LinkedList<SoftReference<K>> cache =
|
||||
new LinkedList<SoftReference<K>>();
|
||||
private final int nSoftReferences;
|
||||
}
|
@ -284,20 +284,20 @@ public class EnumRowStatus extends Enumerated implements Serializable {
|
||||
final static Hashtable<Integer, String> intTable = new Hashtable<>();
|
||||
final static Hashtable<String, Integer> stringTable = new Hashtable<>();
|
||||
static {
|
||||
intTable.put(new Integer(0), "unspecified");
|
||||
intTable.put(new Integer(3), "notReady");
|
||||
intTable.put(new Integer(6), "destroy");
|
||||
intTable.put(new Integer(2), "notInService");
|
||||
intTable.put(new Integer(5), "createAndWait");
|
||||
intTable.put(new Integer(1), "active");
|
||||
intTable.put(new Integer(4), "createAndGo");
|
||||
stringTable.put("unspecified", new Integer(0));
|
||||
stringTable.put("notReady", new Integer(3));
|
||||
stringTable.put("destroy", new Integer(6));
|
||||
stringTable.put("notInService", new Integer(2));
|
||||
stringTable.put("createAndWait", new Integer(5));
|
||||
stringTable.put("active", new Integer(1));
|
||||
stringTable.put("createAndGo", new Integer(4));
|
||||
intTable.put(0, "unspecified");
|
||||
intTable.put(3, "notReady");
|
||||
intTable.put(6, "destroy");
|
||||
intTable.put(2, "notInService");
|
||||
intTable.put(5, "createAndWait");
|
||||
intTable.put(1, "active");
|
||||
intTable.put(4, "createAndGo");
|
||||
stringTable.put("unspecified", 0);
|
||||
stringTable.put("notReady", 3);
|
||||
stringTable.put("destroy", 6);
|
||||
stringTable.put("notInService", 2);
|
||||
stringTable.put("createAndWait", 5);
|
||||
stringTable.put("active", 1);
|
||||
stringTable.put("createAndGo", 4);
|
||||
}
|
||||
|
||||
|
||||
|
@ -71,7 +71,7 @@ abstract public class Enumerated implements Serializable {
|
||||
* the method is illegal or inappropriate.
|
||||
*/
|
||||
public Enumerated(int valueIndex) throws IllegalArgumentException {
|
||||
if (getIntTable().get(new Integer(valueIndex)) == null) {
|
||||
if (getIntTable().get(valueIndex) == null) {
|
||||
throw new IllegalArgumentException() ;
|
||||
}
|
||||
value = valueIndex ;
|
||||
@ -181,7 +181,7 @@ abstract public class Enumerated implements Serializable {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getIntTable().get(new Integer(value)) ;
|
||||
return getIntTable().get(value);
|
||||
}
|
||||
|
||||
|
||||
|
@ -100,7 +100,7 @@ class JJTParserState {
|
||||
|
||||
|
||||
void openNodeScope(Node n) {
|
||||
marks.push(new Integer(mk));
|
||||
marks.push(mk);
|
||||
mk = sp;
|
||||
n.jjtOpen();
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public class SnmpCounter64 extends SnmpValue {
|
||||
* @return The <CODE>Integer</CODE> representation of the value.
|
||||
*/
|
||||
public Integer toInteger() {
|
||||
return new Integer((int)value) ;
|
||||
return (int)value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -146,7 +146,7 @@ public class SnmpInt extends SnmpValue {
|
||||
* @return The <CODE>Integer</CODE> representation of the value.
|
||||
*/
|
||||
public Integer toInteger() {
|
||||
return new Integer((int)value) ;
|
||||
return (int)value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1272,8 +1272,8 @@ public abstract class CommunicatorServer
|
||||
message, // message
|
||||
"State", // attribute name
|
||||
"int", // attribute type
|
||||
new Integer(oldState), // old value
|
||||
new Integer(newState) ); // new value
|
||||
oldState, // old value
|
||||
newState ); // new value
|
||||
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
|
||||
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag,
|
||||
"sendStateChangeNotification","Sending AttributeChangeNotification #"
|
||||
|
@ -569,7 +569,7 @@ public class SnmpAdaptorServer extends CommunicatorServer
|
||||
*/
|
||||
@Override
|
||||
public Integer getTrapPort() {
|
||||
return new Integer(trapPort) ;
|
||||
return trapPort;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -639,7 +639,7 @@ public class SnmpAdaptorServer extends CommunicatorServer
|
||||
*/
|
||||
@Override
|
||||
public Integer getBufferSize() {
|
||||
return new Integer(bufferSize) ;
|
||||
return bufferSize;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,15 +43,15 @@ public abstract class SnmpLcd {
|
||||
|
||||
public void addModelLcd(int id,
|
||||
SnmpModelLcd usmlcd) {
|
||||
models.put(new Integer(id), usmlcd);
|
||||
models.put(id, usmlcd);
|
||||
}
|
||||
|
||||
public SnmpModelLcd getModelLcd(int id) {
|
||||
return models.get(new Integer(id));
|
||||
return models.get(id);
|
||||
}
|
||||
|
||||
public SnmpModelLcd removeModelLcd(int id) {
|
||||
return models.remove(new Integer(id));
|
||||
return models.remove(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2014, 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
|
||||
@ -71,17 +71,10 @@ public class RemoteToCorba implements StateFactory {
|
||||
|
||||
if (orig instanceof Remote) {
|
||||
// Turn remote object into org.omg.CORBA.Object
|
||||
try {
|
||||
// Returns null if JRMP; let next factory try
|
||||
// CNCtx will eventually throw IllegalArgumentException if
|
||||
// no CORBA object gotten
|
||||
return
|
||||
CorbaUtils.remoteToCorba((Remote)orig, ((CNCtx)ctx)._orb);
|
||||
} catch (ClassNotFoundException e) {
|
||||
// RMI-IIOP library not available
|
||||
throw new ConfigurationException(
|
||||
"javax.rmi packages not available");
|
||||
}
|
||||
// Returns null if JRMP; let next factory try
|
||||
// CNCtx will eventually throw IllegalArgumentException if
|
||||
// no CORBA object gotten
|
||||
return CorbaUtils.remoteToCorba((Remote)orig, ((CNCtx)ctx)._orb);
|
||||
}
|
||||
return null; // pass and let next state factory try
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2014, 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
|
||||
@ -86,9 +86,8 @@ class ClientId {
|
||||
try {
|
||||
Class<?> socketFactoryClass =
|
||||
Obj.helper.loadClass(socketFactory);
|
||||
Class<?> objClass = Class.forName("java.lang.Object");
|
||||
this.sockComparator = socketFactoryClass.getMethod(
|
||||
"compare", new Class<?>[]{objClass, objClass});
|
||||
"compare", new Class<?>[]{Object.class, Object.class});
|
||||
Method getDefault = socketFactoryClass.getMethod(
|
||||
"getDefault", new Class<?>[]{});
|
||||
this.factory =
|
||||
|
@ -31,6 +31,7 @@ import java.io.InterruptedIOException;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import javax.net.ssl.SSLSocket;
|
||||
|
||||
@ -42,11 +43,10 @@ import javax.naming.InterruptedNamingException;
|
||||
import javax.naming.ldap.Control;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Arrays;
|
||||
import sun.misc.IOUtils;
|
||||
//import javax.net.SocketFactory;
|
||||
import javax.net.SocketFactory;
|
||||
|
||||
/**
|
||||
* A thread that creates a connection to an LDAP server.
|
||||
@ -219,9 +219,7 @@ public final class Connection implements Runnable {
|
||||
ce.setRootCause(realException);
|
||||
throw ce;
|
||||
} catch (Exception e) {
|
||||
// Class.forName() seems to do more error checking
|
||||
// and will throw IllegalArgumentException and such.
|
||||
// That's why we need to have a catch all here and
|
||||
// We need to have a catch all here and
|
||||
// ignore generic exceptions.
|
||||
// Also catches all IO errors generated by socket creation.
|
||||
CommunicationException ce =
|
||||
@ -238,27 +236,8 @@ public final class Connection implements Runnable {
|
||||
/*
|
||||
* Create an InetSocketAddress using the specified hostname and port number.
|
||||
*/
|
||||
private Object createInetSocketAddress(String host, int port)
|
||||
throws NoSuchMethodException {
|
||||
|
||||
try {
|
||||
Class<?> inetSocketAddressClass =
|
||||
Class.forName("java.net.InetSocketAddress");
|
||||
|
||||
Constructor<?> inetSocketAddressCons =
|
||||
inetSocketAddressClass.getConstructor(new Class<?>[]{
|
||||
String.class, int.class});
|
||||
|
||||
return inetSocketAddressCons.newInstance(new Object[]{
|
||||
host, new Integer(port)});
|
||||
|
||||
} catch (ClassNotFoundException |
|
||||
InstantiationException |
|
||||
InvocationTargetException |
|
||||
IllegalAccessException e) {
|
||||
throw new NoSuchMethodException();
|
||||
|
||||
}
|
||||
private InetSocketAddress createInetSocketAddress(String host, int port) {
|
||||
return new InetSocketAddress(host, port);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -279,83 +258,58 @@ public final class Connection implements Runnable {
|
||||
|
||||
// create the factory
|
||||
|
||||
Class<?> socketFactoryClass = Obj.helper.loadClass(socketFactory);
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends SocketFactory> socketFactoryClass =
|
||||
(Class<? extends SocketFactory>)Obj.helper.loadClass(socketFactory);
|
||||
Method getDefault =
|
||||
socketFactoryClass.getMethod("getDefault", new Class<?>[]{});
|
||||
Object factory = getDefault.invoke(null, new Object[]{});
|
||||
SocketFactory factory = (SocketFactory) getDefault.invoke(null, new Object[]{});
|
||||
|
||||
// create the socket
|
||||
|
||||
Method createSocket = null;
|
||||
|
||||
if (connectTimeout > 0) {
|
||||
|
||||
try {
|
||||
createSocket = socketFactoryClass.getMethod("createSocket",
|
||||
new Class<?>[]{});
|
||||
InetSocketAddress endpoint =
|
||||
createInetSocketAddress(host, port);
|
||||
|
||||
Method connect = Socket.class.getMethod("connect",
|
||||
new Class<?>[]{Class.forName("java.net.SocketAddress"),
|
||||
int.class});
|
||||
Object endpoint = createInetSocketAddress(host, port);
|
||||
// unconnected socket
|
||||
socket = factory.createSocket();
|
||||
|
||||
// unconnected socket
|
||||
socket =
|
||||
(Socket)createSocket.invoke(factory, new Object[]{});
|
||||
|
||||
if (debug) {
|
||||
System.err.println("Connection: creating socket with " +
|
||||
if (debug) {
|
||||
System.err.println("Connection: creating socket with " +
|
||||
"a timeout using supplied socket factory");
|
||||
}
|
||||
|
||||
// connected socket
|
||||
connect.invoke(socket, new Object[]{
|
||||
endpoint, new Integer(connectTimeout)});
|
||||
|
||||
} catch (NoSuchMethodException e) {
|
||||
// continue (but ignore connectTimeout)
|
||||
}
|
||||
|
||||
// connected socket
|
||||
socket.connect(endpoint, connectTimeout);
|
||||
}
|
||||
|
||||
// continue (but ignore connectTimeout)
|
||||
if (socket == null) {
|
||||
createSocket = socketFactoryClass.getMethod("createSocket",
|
||||
new Class<?>[]{String.class, int.class});
|
||||
|
||||
if (debug) {
|
||||
System.err.println("Connection: creating socket using " +
|
||||
"supplied socket factory");
|
||||
}
|
||||
// connected socket
|
||||
socket = (Socket) createSocket.invoke(factory,
|
||||
new Object[]{host, new Integer(port)});
|
||||
socket = factory.createSocket(host, port);
|
||||
}
|
||||
} else {
|
||||
|
||||
if (connectTimeout > 0) {
|
||||
|
||||
try {
|
||||
Constructor<Socket> socketCons =
|
||||
Socket.class.getConstructor(new Class<?>[]{});
|
||||
InetSocketAddress endpoint = createInetSocketAddress(host, port);
|
||||
|
||||
Method connect = Socket.class.getMethod("connect",
|
||||
new Class<?>[]{Class.forName("java.net.SocketAddress"),
|
||||
int.class});
|
||||
Object endpoint = createInetSocketAddress(host, port);
|
||||
|
||||
socket = socketCons.newInstance(new Object[]{});
|
||||
socket = new Socket();
|
||||
|
||||
if (debug) {
|
||||
System.err.println("Connection: creating socket with " +
|
||||
"a timeout");
|
||||
}
|
||||
connect.invoke(socket, new Object[]{
|
||||
endpoint, new Integer(connectTimeout)});
|
||||
|
||||
} catch (NoSuchMethodException e) {
|
||||
// continue (but ignore connectTimeout)
|
||||
}
|
||||
socket.connect(endpoint, connectTimeout);
|
||||
}
|
||||
|
||||
// continue (but ignore connectTimeout)
|
||||
|
||||
if (socket == null) {
|
||||
if (debug) {
|
||||
System.err.println("Connection: creating socket");
|
||||
|
@ -406,7 +406,7 @@ public final class LdapPoolManager {
|
||||
try {
|
||||
return Integer.getInteger(propName, defVal);
|
||||
} catch (SecurityException e) {
|
||||
return new Integer(defVal);
|
||||
return defVal;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2014, 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
|
||||
@ -30,32 +30,10 @@ import java.net.URL;
|
||||
|
||||
abstract class VersionHelper {
|
||||
|
||||
private static VersionHelper helper = null;
|
||||
private static final VersionHelper helper = new VersionHelper12();
|
||||
|
||||
VersionHelper() {} // Disallow anyone from creating one of these.
|
||||
|
||||
static {
|
||||
try {
|
||||
Class.forName("java.net.URLClassLoader"); // 1.2 test
|
||||
Class.forName("java.security.PrivilegedAction"); // 1.2 test
|
||||
helper = (VersionHelper)
|
||||
Class.forName(
|
||||
"com.sun.jndi.ldap.VersionHelper12").newInstance();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
// Use 1.1 helper if 1.2 test fails, or if we cannot create 1.2 helper
|
||||
if (helper == null) {
|
||||
try {
|
||||
helper = (VersionHelper)
|
||||
Class.forName(
|
||||
"com.sun.jndi.ldap.VersionHelper11").newInstance();
|
||||
} catch (Exception e) {
|
||||
// should never happen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static VersionHelper getVersionHelper() {
|
||||
return helper;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2014, 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
|
||||
@ -28,16 +28,18 @@ package com.sun.jndi.toolkit.corba;
|
||||
// Needed for RMI/IIOP
|
||||
import java.rmi.Remote;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Properties;
|
||||
import java.util.Enumeration;
|
||||
import java.applet.Applet;
|
||||
|
||||
import org.omg.CORBA.ORB;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.ConfigurationException;
|
||||
import javax.rmi.CORBA.Stub;
|
||||
import javax.rmi.PortableRemoteObject;
|
||||
|
||||
/**
|
||||
* Contains utilities for performing CORBA-related tasks:
|
||||
@ -76,71 +78,43 @@ public class CorbaUtils {
|
||||
* @param orb The non-null ORB to connect the remote object to
|
||||
* @return The CORBA Object for remoteObj; null if <tt>remoteObj</tt>
|
||||
* is a JRMP implementation or JRMP stub.
|
||||
* @exception ClassNotFoundException The RMI-IIOP package is not available
|
||||
* @exception ConfigurationException The CORBA Object cannot be obtained
|
||||
* because of configuration problems.
|
||||
*/
|
||||
public static org.omg.CORBA.Object remoteToCorba(Remote remoteObj, ORB orb)
|
||||
throws ClassNotFoundException, ConfigurationException {
|
||||
synchronized (CorbaUtils.class) {
|
||||
if (toStubMethod == null) {
|
||||
initMethodHandles();
|
||||
}
|
||||
}
|
||||
throws ConfigurationException {
|
||||
|
||||
// First, get remoteObj's stub
|
||||
|
||||
// javax.rmi.CORBA.Stub stub = PortableRemoteObject.toStub(remoteObj);
|
||||
|
||||
java.lang.Object stub;
|
||||
Remote stub;
|
||||
|
||||
try {
|
||||
stub = toStubMethod.invoke(null, new java.lang.Object[]{remoteObj});
|
||||
|
||||
} catch (InvocationTargetException e) {
|
||||
Throwable realException = e.getTargetException();
|
||||
// realException.printStackTrace();
|
||||
|
||||
stub = PortableRemoteObject.toStub(remoteObj);
|
||||
} catch (Throwable t) {
|
||||
ConfigurationException ce = new ConfigurationException(
|
||||
"Problem with PortableRemoteObject.toStub(); object not exported or stub not found");
|
||||
ce.setRootCause(realException);
|
||||
throw ce;
|
||||
|
||||
} catch (IllegalAccessException e) {
|
||||
ConfigurationException ce = new ConfigurationException(
|
||||
"Cannot invoke javax.rmi.PortableRemoteObject.toStub(java.rmi.Remote)");
|
||||
|
||||
ce.setRootCause(e);
|
||||
ce.setRootCause(t);
|
||||
throw ce;
|
||||
}
|
||||
|
||||
// Next, make sure that the stub is javax.rmi.CORBA.Stub
|
||||
|
||||
if (!corbaStubClass.isInstance(stub)) {
|
||||
if (!(stub instanceof Stub)) {
|
||||
return null; // JRMP implementation or JRMP stub
|
||||
}
|
||||
|
||||
// Next, make sure that the stub is connected
|
||||
// Invoke stub.connect(orb)
|
||||
try {
|
||||
connectMethod.invoke(stub, new java.lang.Object[]{orb});
|
||||
|
||||
} catch (InvocationTargetException e) {
|
||||
Throwable realException = e.getTargetException();
|
||||
// realException.printStackTrace();
|
||||
|
||||
if (!(realException instanceof java.rmi.RemoteException)) {
|
||||
ConfigurationException ce = new ConfigurationException(
|
||||
"Problem invoking javax.rmi.CORBA.Stub.connect()");
|
||||
ce.setRootCause(realException);
|
||||
throw ce;
|
||||
}
|
||||
((Stub) stub).connect(orb);
|
||||
} catch (RemoteException e) {
|
||||
// ignore RemoteException because stub might have already
|
||||
// been connected
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (Throwable t) {
|
||||
ConfigurationException ce = new ConfigurationException(
|
||||
"Cannot invoke javax.rmi.CORBA.Stub.connect()");
|
||||
ce.setRootCause(e);
|
||||
"Problem invoking javax.rmi.CORBA.Stub.connect()");
|
||||
ce.setRootCause(t);
|
||||
throw ce;
|
||||
}
|
||||
// Finally, return stub
|
||||
@ -192,83 +166,13 @@ public class CorbaUtils {
|
||||
|
||||
// Get Applet from environment
|
||||
if (env != null) {
|
||||
Object applet = env.get(Context.APPLET);
|
||||
Applet applet = (Applet) env.get(Context.APPLET);
|
||||
if (applet != null) {
|
||||
// Create ORBs for an applet
|
||||
return initAppletORB(applet, orbProp);
|
||||
// Create ORBs using applet and orbProp
|
||||
return ORB.init(applet, orbProp);
|
||||
}
|
||||
}
|
||||
|
||||
// Create ORBs using orbProp for a standalone application
|
||||
return ORB.init(new String[0], orbProp);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns a new ORB instance for the given applet
|
||||
* without creating a static dependency on java.applet.
|
||||
*/
|
||||
private static ORB initAppletORB(Object applet, Properties orbProp) {
|
||||
try {
|
||||
Class<?> appletClass = Class.forName("java.applet.Applet", true, null);
|
||||
if (!appletClass.isInstance(applet)) {
|
||||
throw new ClassCastException(applet.getClass().getName());
|
||||
}
|
||||
|
||||
// invoke the static method ORB.init(applet, orbProp);
|
||||
Method method = ORB.class.getMethod("init", appletClass, Properties.class);
|
||||
return (ORB) method.invoke(null, applet, orbProp);
|
||||
} catch (ClassNotFoundException e) {
|
||||
// java.applet.Applet doesn't exist and the applet parameter is
|
||||
// non-null; so throw CCE
|
||||
throw new ClassCastException(applet.getClass().getName());
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new AssertionError(e);
|
||||
} catch (InvocationTargetException e) {
|
||||
Throwable cause = e.getCause();
|
||||
if (cause instanceof RuntimeException) {
|
||||
throw (RuntimeException) cause;
|
||||
} else if (cause instanceof Error) {
|
||||
throw (Error) cause;
|
||||
}
|
||||
throw new AssertionError(e);
|
||||
} catch (IllegalAccessException iae) {
|
||||
throw new AssertionError(iae);
|
||||
}
|
||||
}
|
||||
|
||||
// Fields used for reflection of RMI-IIOP
|
||||
private static Method toStubMethod = null;
|
||||
private static Method connectMethod = null;
|
||||
private static Class<?> corbaStubClass = null;
|
||||
/**
|
||||
* Initializes reflection method handles for RMI-IIOP.
|
||||
* @exception ClassNotFoundException javax.rmi.CORBA.* not available
|
||||
*/
|
||||
private static void initMethodHandles() throws ClassNotFoundException {
|
||||
// Get javax.rmi.CORBA.Stub class
|
||||
corbaStubClass = Class.forName("javax.rmi.CORBA.Stub");
|
||||
|
||||
// Get javax.rmi.CORBA.Stub.connect(org.omg.CORBA.ORB) method
|
||||
|
||||
try {
|
||||
connectMethod = corbaStubClass.getMethod("connect",
|
||||
new Class<?>[] {org.omg.CORBA.ORB.class});
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new IllegalStateException(
|
||||
"No method definition for javax.rmi.CORBA.Stub.connect(org.omg.CORBA.ORB)");
|
||||
}
|
||||
|
||||
// Get javax.rmi.PortableRemoteObject class
|
||||
Class<?> proClass = Class.forName("javax.rmi.PortableRemoteObject");
|
||||
|
||||
// Get javax.rmi.PortableRemoteObject.toStub(java.rmi.Remote) method
|
||||
try {
|
||||
toStubMethod = proClass.getMethod("toStub",
|
||||
new Class<?>[] {java.rmi.Remote.class});
|
||||
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new IllegalStateException(
|
||||
"No method definition for javax.rmi.PortableRemoteObject.toStub(java.rmi.Remote)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2014, 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
|
||||
@ -32,6 +32,7 @@ import javax.security.sasl.Sasl;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.MessageDigest;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
@ -159,7 +160,7 @@ abstract class CramMD5Base {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
|
||||
/* digest the key if longer than 64 bytes */
|
||||
if (key.length > 64) {
|
||||
if (key.length > MD5_BLOCKSIZE) {
|
||||
key = md5.digest(key);
|
||||
}
|
||||
|
||||
@ -169,13 +170,9 @@ abstract class CramMD5Base {
|
||||
int i;
|
||||
|
||||
/* store key in pads */
|
||||
for (i = 0; i < MD5_BLOCKSIZE; i++) {
|
||||
for ( ; i < key.length; i++) {
|
||||
ipad[i] = key[i];
|
||||
opad[i] = key[i];
|
||||
}
|
||||
ipad[i] = 0x00;
|
||||
opad[i] = 0x00;
|
||||
for (i = 0; i < key.length; i++) {
|
||||
ipad[i] = key[i];
|
||||
opad[i] = key[i];
|
||||
}
|
||||
|
||||
/* XOR key with pads */
|
||||
@ -207,6 +204,11 @@ abstract class CramMD5Base {
|
||||
}
|
||||
}
|
||||
|
||||
Arrays.fill(ipad, (byte)0);
|
||||
Arrays.fill(opad, (byte)0);
|
||||
ipad = null;
|
||||
opad = null;
|
||||
|
||||
return (digestString.toString());
|
||||
}
|
||||
|
||||
|
@ -1410,7 +1410,7 @@ abstract class DigestMD5Base extends AbstractSaslImpl {
|
||||
if (logger.isLoggable(Level.FINEST)) {
|
||||
logger.log(Level.FINEST,
|
||||
"DIGEST33:Expecting sequence num: {0}",
|
||||
new Integer(peerSeqNum));
|
||||
peerSeqNum);
|
||||
traceOutput(DP_CLASS_NAME, "unwrap", "DIGEST34:incoming: ",
|
||||
encryptedMsg);
|
||||
}
|
||||
|
@ -439,7 +439,7 @@ final class DigestMD5Client extends DigestMD5Base implements SaslClient {
|
||||
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
logger.log(Level.FINE, "DIGEST61:Raw send size: {0}",
|
||||
new Integer(rawSendSize));
|
||||
rawSendSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -275,9 +275,9 @@ final class GssKrb5Client extends GssKrb5Base implements SaslClient {
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
logger.log(Level.FINE,
|
||||
"KRB5CLNT07:Client max recv size: {0}; server max recv size: {1}; rawSendSize: {2}",
|
||||
new Object[] {new Integer(recvMaxBufSize),
|
||||
new Integer(srvMaxBufSize),
|
||||
new Integer(rawSendSize)});
|
||||
new Object[] {recvMaxBufSize,
|
||||
srvMaxBufSize,
|
||||
rawSendSize});
|
||||
}
|
||||
|
||||
// Construct negotiated security layers and client's max
|
||||
|
@ -222,7 +222,7 @@ final class GssKrb5Server extends GssKrb5Base implements SaslServer {
|
||||
logger.log(Level.FINE,
|
||||
"KRB5SRV06:Supported protections: {0}; recv max buf size: {1}",
|
||||
new Object[]{allQop,
|
||||
new Integer(recvMaxBufSize)});
|
||||
recvMaxBufSize});
|
||||
}
|
||||
|
||||
handshakeStage = 2; // progress to next stage
|
||||
@ -293,9 +293,9 @@ final class GssKrb5Server extends GssKrb5Base implements SaslServer {
|
||||
Boolean.valueOf(integrity)});
|
||||
logger.log(Level.FINE,
|
||||
"KRB5SRV11:Client max recv size: {0}; server max send size: {1}; rawSendSize: {2}",
|
||||
new Object[] {new Integer(clntMaxBufSize),
|
||||
new Integer(sendMaxBufSize),
|
||||
new Integer(rawSendSize)});
|
||||
new Object[] {clntMaxBufSize,
|
||||
sendMaxBufSize,
|
||||
rawSendSize});
|
||||
}
|
||||
|
||||
// Get authorization identity, if any
|
||||
|
@ -286,7 +286,7 @@ public abstract class AbstractSaslImpl {
|
||||
|
||||
// Message id supplied by caller as part of traceTag
|
||||
logger.logp(lev, srcClass, srcMethod, "{0} ( {1} ): {2}",
|
||||
new Object[] {traceTag, new Integer(origlen), content});
|
||||
new Object[] {traceTag, origlen, content});
|
||||
} catch (Exception e) {
|
||||
logger.logp(Level.WARNING, srcClass, srcMethod,
|
||||
"SASLIMPL09:Error generating trace output: {0}", e);
|
||||
|
@ -211,7 +211,7 @@ public class ContextManager {
|
||||
}
|
||||
|
||||
private void setCurrentFrameIndex(ThreadInfo tinfo, int index) {
|
||||
tinfo.setUserObject(new Integer(index));
|
||||
tinfo.setUserObject(index);
|
||||
//### In fact, the value may not have changed at this point.
|
||||
//### We need to signal that the user attempted to change it,
|
||||
//### however, so that the selection can be "warped" to the
|
||||
|
@ -84,7 +84,7 @@ class Commands {
|
||||
MessageOutput.println("Current thread isnt suspended.");
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
MessageOutput.println("Requested stack frame is no longer active:",
|
||||
new Object []{new Integer(stackFrame)});
|
||||
new Object []{stackFrame});
|
||||
}
|
||||
}
|
||||
MessageOutput.printPrompt();
|
||||
@ -942,14 +942,14 @@ class Commands {
|
||||
}
|
||||
if (pc != -1) {
|
||||
MessageOutput.println("stack frame dump with pc",
|
||||
new Object [] {new Integer(frameNumber + 1),
|
||||
new Object [] {(frameNumber + 1),
|
||||
meth.declaringType().name(),
|
||||
meth.name(),
|
||||
methodInfo,
|
||||
Long.valueOf(pc)});
|
||||
} else {
|
||||
MessageOutput.println("stack frame dump",
|
||||
new Object [] {new Integer(frameNumber + 1),
|
||||
new Object [] {(frameNumber + 1),
|
||||
meth.declaringType().name(),
|
||||
meth.name(),
|
||||
methodInfo});
|
||||
@ -2093,8 +2093,8 @@ class Commands {
|
||||
VirtualMachineManager vmm) {
|
||||
MessageOutput.println("minus version",
|
||||
new Object [] { debuggerName,
|
||||
new Integer(vmm.majorInterfaceVersion()),
|
||||
new Integer(vmm.minorInterfaceVersion()),
|
||||
vmm.majorInterfaceVersion(),
|
||||
vmm.minorInterfaceVersion(),
|
||||
System.getProperty("java.version")});
|
||||
if (Env.connection() != null) {
|
||||
try {
|
||||
|
@ -241,7 +241,7 @@ public class TTY implements EventNotifier {
|
||||
}
|
||||
if (line != null) {
|
||||
MessageOutput.println("source line number and line",
|
||||
new Object [] {new Integer(loc.lineNumber()),
|
||||
new Object [] {loc.lineNumber(),
|
||||
line});
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public abstract class JavaLazyReadObject extends JavaHeapObject {
|
||||
// make Integer or Long for given object ID
|
||||
protected static Number makeId(long id) {
|
||||
if ((id & ~Snapshot.SMALL_ID_MASK) == 0) {
|
||||
return new Integer((int)id);
|
||||
return (int)id;
|
||||
} else {
|
||||
return id;
|
||||
}
|
||||
|
@ -581,7 +581,7 @@ public class Snapshot {
|
||||
// Internals only below this point
|
||||
private Number makeId(long id) {
|
||||
if (identifierSize == 4) {
|
||||
return new Integer((int)id);
|
||||
return (int)id;
|
||||
} else {
|
||||
return id;
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ public class HprofReader extends Reader /* imports */ implements ArrayTypeCodes
|
||||
String nm = getNameFromID(classNameID).replace('/', '.');
|
||||
classNameFromObjectID.put(classIdI, nm);
|
||||
if (classNameFromSerialNo != null) {
|
||||
classNameFromSerialNo.put(new Integer(serialNo), nm);
|
||||
classNameFromSerialNo.put(serialNo, nm);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -297,7 +297,7 @@ public class HprofReader extends Reader /* imports */ implements ArrayTypeCodes
|
||||
String methodSig = getNameFromID(readID());
|
||||
String sourceFile = getNameFromID(readID());
|
||||
int classSer = in.readInt();
|
||||
String className = classNameFromSerialNo.get(new Integer(classSer));
|
||||
String className = classNameFromSerialNo.get(classSer);
|
||||
int lineNumber = in.readInt();
|
||||
if (lineNumber < StackFrame.LINE_NUMBER_NATIVE) {
|
||||
warn("Weird stack frame line number: " + lineNumber);
|
||||
@ -324,7 +324,7 @@ public class HprofReader extends Reader /* imports */ implements ArrayTypeCodes
|
||||
throw new IOException("Stack frame " + toHex(fid) + " not found");
|
||||
}
|
||||
}
|
||||
stackTraces.put(new Integer(serialNo),
|
||||
stackTraces.put(serialNo,
|
||||
new StackTrace(frames));
|
||||
}
|
||||
break;
|
||||
@ -404,7 +404,7 @@ public class HprofReader extends Reader /* imports */ implements ArrayTypeCodes
|
||||
int threadSeq = in.readInt();
|
||||
int stackSeq = in.readInt();
|
||||
bytesLeft -= identifierSize + 8;
|
||||
threadObjects.put(new Integer(threadSeq),
|
||||
threadObjects.put(threadSeq,
|
||||
new ThreadObject(id, stackSeq));
|
||||
break;
|
||||
}
|
||||
@ -610,7 +610,7 @@ public class HprofReader extends Reader /* imports */ implements ArrayTypeCodes
|
||||
|
||||
private ThreadObject getThreadObjectFromSequence(int threadSeq)
|
||||
throws IOException {
|
||||
ThreadObject to = threadObjects.get(new Integer(threadSeq));
|
||||
ThreadObject to = threadObjects.get(threadSeq);
|
||||
if (to == null) {
|
||||
throw new IOException("Thread " + threadSeq +
|
||||
" not found for JNI local ref");
|
||||
@ -638,7 +638,7 @@ public class HprofReader extends Reader /* imports */ implements ArrayTypeCodes
|
||||
if (stackTraces == null) {
|
||||
return null;
|
||||
}
|
||||
StackTrace result = stackTraces.get(new Integer(ser));
|
||||
StackTrace result = stackTraces.get(ser);
|
||||
if (result == null) {
|
||||
warn("Stack trace not found for serial # " + ser);
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ class ObjectQuery extends ClassQuery {
|
||||
final JavaField[] fields = obj.getClazz().getFieldsForInstance();
|
||||
Integer[] hack = new Integer[things.length];
|
||||
for (int i = 0; i < things.length; i++) {
|
||||
hack[i] = new Integer(i);
|
||||
hack[i] = i;
|
||||
}
|
||||
ArraySorter.sort(hack, new Comparer() {
|
||||
public int compare(Object lhs, Object rhs) {
|
||||
|
@ -143,7 +143,7 @@ public class ConcreteMethodImpl extends MethodImpl {
|
||||
* Find the locations which match the line number
|
||||
* passed in.
|
||||
*/
|
||||
List<Location> list = info.lineMapper.get(new Integer(lineNumber));
|
||||
List<Location> list = info.lineMapper.get(lineNumber);
|
||||
|
||||
if (list == null) {
|
||||
list = new ArrayList<Location>(0);
|
||||
@ -329,7 +329,7 @@ public class ConcreteMethodImpl extends MethodImpl {
|
||||
lineLocations.add(loc);
|
||||
|
||||
// Add to the line -> locations map
|
||||
Integer key = new Integer(lineNumber);
|
||||
Integer key = lineNumber;
|
||||
List<Location> mappedLocs = lineMapper.get(key);
|
||||
if (mappedLocs == null) {
|
||||
mappedLocs = new ArrayList<Location>(1);
|
||||
@ -399,7 +399,7 @@ public class ConcreteMethodImpl extends MethodImpl {
|
||||
lineLocations.add(loc);
|
||||
|
||||
// Add to the line -> locations map
|
||||
Integer key = new Integer(lineNumber);
|
||||
Integer key = lineNumber;
|
||||
List<Location> mappedLocs = lineMapper.get(key);
|
||||
if (mappedLocs == null) {
|
||||
mappedLocs = new ArrayList<Location>(1);
|
||||
|
@ -529,7 +529,7 @@ implements ReferenceType {
|
||||
* to filter that ordered collection.
|
||||
*/
|
||||
List<Method> list = allMethods();
|
||||
list.retainAll(map.values());
|
||||
list.retainAll(new HashSet<Method>(map.values()));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,6 @@ import sun.awt.AWTAccessor;
|
||||
import sun.awt.ConstrainableGraphics;
|
||||
import sun.awt.SubRegionShowable;
|
||||
import sun.awt.SunToolkit;
|
||||
import sun.awt.WindowClosingListener;
|
||||
import sun.awt.CausedFocusEvent;
|
||||
import sun.awt.EmbeddedFrame;
|
||||
import sun.awt.dnd.SunDropTargetEvent;
|
||||
@ -544,8 +543,6 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
transient MouseWheelListener mouseWheelListener;
|
||||
transient InputMethodListener inputMethodListener;
|
||||
|
||||
transient RuntimeException windowClosingException = null;
|
||||
|
||||
/** Internal, constants for serialization */
|
||||
final static String actionListenerK = "actionL";
|
||||
final static String adjustmentListenerK = "adjustmentL";
|
||||
@ -4959,16 +4956,6 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
}
|
||||
break;
|
||||
|
||||
case WindowEvent.WINDOW_CLOSING:
|
||||
if (toolkit instanceof WindowClosingListener) {
|
||||
windowClosingException = ((WindowClosingListener)
|
||||
toolkit).windowClosingNotify((WindowEvent)e);
|
||||
if (checkWindowClosingException()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -5023,21 +5010,6 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 8. Special handling for 4061116 : Hook for browser to close modal
|
||||
* dialogs.
|
||||
*/
|
||||
if (id == WindowEvent.WINDOW_CLOSING && !e.isConsumed()) {
|
||||
if (toolkit instanceof WindowClosingListener) {
|
||||
windowClosingException =
|
||||
((WindowClosingListener)toolkit).
|
||||
windowClosingDelivered((WindowEvent)e);
|
||||
if (checkWindowClosingException()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 9. Allow the peer to process the event.
|
||||
* Except KeyEvents, they will be processed by peer after
|
||||
@ -5145,20 +5117,6 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean checkWindowClosingException() {
|
||||
if (windowClosingException != null) {
|
||||
if (this instanceof Dialog) {
|
||||
((Dialog)this).interruptBlocking();
|
||||
} else {
|
||||
windowClosingException.fillInStackTrace();
|
||||
windowClosingException.printStackTrace();
|
||||
windowClosingException = null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean areInputMethodsEnabled() {
|
||||
// in 1.2, we assume input method support is required for all
|
||||
// components that handle key events, but components can turn off
|
||||
|
@ -2910,17 +2910,10 @@ public class Container extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
Runnable pumpEventsForHierarchy = new Runnable() {
|
||||
public void run() {
|
||||
EventDispatchThread dispatchThread =
|
||||
(EventDispatchThread)Thread.currentThread();
|
||||
dispatchThread.pumpEventsForHierarchy(
|
||||
new Conditional() {
|
||||
public boolean evaluate() {
|
||||
return ((windowClosingException == null) && (nativeContainer.modalComp != null)) ;
|
||||
}
|
||||
}, Container.this);
|
||||
}
|
||||
Runnable pumpEventsForHierarchy = () -> {
|
||||
EventDispatchThread dispatchThread = (EventDispatchThread)Thread.currentThread();
|
||||
dispatchThread.pumpEventsForHierarchy(() -> nativeContainer.modalComp != null,
|
||||
Container.this);
|
||||
};
|
||||
|
||||
if (EventQueue.isDispatchThread()) {
|
||||
@ -2938,8 +2931,7 @@ public class Container extends Component {
|
||||
postEvent(new PeerEvent(this,
|
||||
pumpEventsForHierarchy,
|
||||
PeerEvent.PRIORITY_EVENT));
|
||||
while ((windowClosingException == null) &&
|
||||
(nativeContainer.modalComp != null))
|
||||
while (nativeContainer.modalComp != null)
|
||||
{
|
||||
try {
|
||||
getTreeLock().wait();
|
||||
@ -2949,10 +2941,6 @@ public class Container extends Component {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (windowClosingException != null) {
|
||||
windowClosingException.fillInStackTrace();
|
||||
throw windowClosingException;
|
||||
}
|
||||
if (predictedFocusOwner != null) {
|
||||
KeyboardFocusManager.getCurrentKeyboardFocusManager().
|
||||
dequeueKeyEvents(time, predictedFocusOwner);
|
||||
|
@ -40,6 +40,7 @@ import sun.awt.PeerEvent;
|
||||
import sun.awt.util.IdentityArrayList;
|
||||
import sun.awt.util.IdentityLinkedList;
|
||||
import java.security.AccessControlException;
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
/**
|
||||
* A Dialog is a top-level window with a title and a border
|
||||
@ -1044,13 +1045,6 @@ public class Dialog extends Window {
|
||||
predictedFocusOwner = getMostRecentFocusOwner();
|
||||
if (conditionalShow(predictedFocusOwner, time)) {
|
||||
modalFilter = ModalEventFilter.createFilterForDialog(this);
|
||||
final Conditional cond = new Conditional() {
|
||||
@Override
|
||||
public boolean evaluate() {
|
||||
return windowClosingException == null;
|
||||
}
|
||||
};
|
||||
|
||||
// if this dialog is toolkit-modal, the filter should be added
|
||||
// to all EDTs (for all AppContexts)
|
||||
if (modalityType == ModalityType.TOOLKIT_MODAL) {
|
||||
@ -1063,10 +1057,7 @@ public class Dialog extends Window {
|
||||
EventQueue eventQueue = (EventQueue)appContext.get(AppContext.EVENT_QUEUE_KEY);
|
||||
// it may occur that EDT for appContext hasn't been started yet, so
|
||||
// we post an empty invocation event to trigger EDT initialization
|
||||
Runnable createEDT = new Runnable() {
|
||||
public void run() {};
|
||||
};
|
||||
eventQueue.postEvent(new InvocationEvent(this, createEDT));
|
||||
eventQueue.postEvent(new InvocationEvent(this, () -> {}));
|
||||
EventDispatchThread edt = eventQueue.getDispatchThread();
|
||||
edt.addEventFilter(modalFilter);
|
||||
}
|
||||
@ -1075,12 +1066,8 @@ public class Dialog extends Window {
|
||||
modalityPushed();
|
||||
try {
|
||||
final EventQueue eventQueue = AccessController.doPrivileged(
|
||||
new PrivilegedAction<EventQueue>() {
|
||||
public EventQueue run() {
|
||||
return Toolkit.getDefaultToolkit().getSystemEventQueue();
|
||||
}
|
||||
});
|
||||
secondaryLoop = eventQueue.createSecondaryLoop(cond, modalFilter, 0);
|
||||
(PrivilegedAction<EventQueue>) Toolkit.getDefaultToolkit()::getSystemEventQueue);
|
||||
secondaryLoop = eventQueue.createSecondaryLoop(() -> true, modalFilter, 0);
|
||||
if (!secondaryLoop.enter()) {
|
||||
secondaryLoop = null;
|
||||
}
|
||||
@ -1102,11 +1089,6 @@ public class Dialog extends Window {
|
||||
edt.removeEventFilter(modalFilter);
|
||||
}
|
||||
}
|
||||
|
||||
if (windowClosingException != null) {
|
||||
windowClosingException.fillInStackTrace();
|
||||
throw windowClosingException;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (predictedFocusOwner != null) {
|
||||
@ -1134,16 +1116,6 @@ public class Dialog extends Window {
|
||||
}
|
||||
}
|
||||
|
||||
void interruptBlocking() {
|
||||
if (isModal()) {
|
||||
disposeImpl();
|
||||
} else if (windowClosingException != null) {
|
||||
windowClosingException.fillInStackTrace();
|
||||
windowClosingException.printStackTrace();
|
||||
windowClosingException = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void hideAndDisposePreHandler() {
|
||||
isInHide = true;
|
||||
synchronized (getTreeLock()) {
|
||||
|
@ -245,7 +245,14 @@ public final class SplashScreen {
|
||||
public Rectangle getBounds() throws IllegalStateException {
|
||||
synchronized (SplashScreen.class) {
|
||||
checkVisible();
|
||||
return _getBounds(splashPtr);
|
||||
float scale = _getScaleFactor(splashPtr);
|
||||
Rectangle bounds = _getBounds(splashPtr);
|
||||
assert scale > 0;
|
||||
if (scale > 0 && scale != 1) {
|
||||
bounds.setSize((int) (bounds.getWidth() / scale),
|
||||
(int) (bounds.getWidth() / scale));
|
||||
}
|
||||
return bounds;
|
||||
}
|
||||
}
|
||||
|
||||
@ -287,10 +294,19 @@ public final class SplashScreen {
|
||||
public Graphics2D createGraphics() throws IllegalStateException {
|
||||
synchronized (SplashScreen.class) {
|
||||
if (image==null) {
|
||||
Dimension dim = getSize();
|
||||
image = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_ARGB);
|
||||
// get unscaled splash image size
|
||||
Dimension dim = _getBounds(splashPtr).getSize();
|
||||
image = new BufferedImage(dim.width, dim.height,
|
||||
BufferedImage.TYPE_INT_ARGB);
|
||||
}
|
||||
return image.createGraphics();
|
||||
float scale = _getScaleFactor(splashPtr);
|
||||
Graphics2D g = image.createGraphics();
|
||||
assert (scale > 0);
|
||||
if (scale <= 0) {
|
||||
scale = 1;
|
||||
}
|
||||
g.scale(scale, scale);
|
||||
return g;
|
||||
}
|
||||
}
|
||||
|
||||
@ -401,5 +417,6 @@ public final class SplashScreen {
|
||||
private native static String _getImageFileName(long splashPtr);
|
||||
private native static String _getImageJarName(long SplashPtr);
|
||||
private native static boolean _setImageData(long SplashPtr, byte[] data);
|
||||
private native static float _getScaleFactor(long SplashPtr);
|
||||
|
||||
};
|
||||
|
@ -22,10 +22,10 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.beans;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import javax.swing.SwingContainer;
|
||||
|
||||
/**
|
||||
* A BeanDescriptor provides global information about a "bean",
|
||||
@ -69,6 +69,23 @@ public class BeanDescriptor extends FeatureDescriptor {
|
||||
name = name.substring(name.indexOf('.')+1);
|
||||
}
|
||||
setName(name);
|
||||
|
||||
JavaBean annotation = beanClass.getAnnotation(JavaBean.class);
|
||||
if (annotation != null) {
|
||||
setPreferred(true);
|
||||
String description = annotation.description();
|
||||
if (!description.isEmpty()) {
|
||||
setShortDescription(description);
|
||||
}
|
||||
}
|
||||
SwingContainer container = beanClass.getAnnotation(SwingContainer.class);
|
||||
if (container != null) {
|
||||
setValue("isContainer", container.value());
|
||||
String delegate = container.delegate();
|
||||
if (!delegate.isEmpty()) {
|
||||
setValue("containerDelegate", delegate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
129
jdk/src/share/classes/java/beans/BeanProperty.java
Normal file
129
jdk/src/share/classes/java/beans/BeanProperty.java
Normal file
@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 java.beans;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* An annotation used to specify some property-related information
|
||||
* for the automatically generated {@link BeanInfo} classes.
|
||||
* This annotation is not used if the annotated class
|
||||
* has a corresponding user-defined {@code BeanInfo} class,
|
||||
* which does not imply the automatic analysis.
|
||||
*
|
||||
* @see BeanInfo#getPropertyDescriptors
|
||||
* @since 1.9
|
||||
*
|
||||
* @author Sergey A. Malenkov
|
||||
*/
|
||||
@Documented
|
||||
@Target({METHOD})
|
||||
@Retention(RUNTIME)
|
||||
public @interface BeanProperty {
|
||||
/**
|
||||
* The value that indicates whether the annotated property can be
|
||||
* a {@link PropertyDescriptor#isBound bound} property or not.
|
||||
* This value applies only to the beans that have the
|
||||
* {@link PropertyChangeListener propertyChange} event set.
|
||||
*
|
||||
* @return {@code true} if the annotated property can be a bound property;
|
||||
* {@code false} otherwise.
|
||||
*/
|
||||
boolean bound() default true;
|
||||
|
||||
/**
|
||||
* The value that indicates whether the annotated property is
|
||||
* an {@link PropertyDescriptor#isExpert expert} property or not.
|
||||
*
|
||||
* @return {@code true} if the annotated property is an expert property;
|
||||
* {@code false} otherwise.
|
||||
*/
|
||||
boolean expert() default false;
|
||||
|
||||
/**
|
||||
* The value that indicates whether the annotated property is
|
||||
* a {@link PropertyDescriptor#isHidden hidden} property or not.
|
||||
*
|
||||
* @return {@code true} if the annotated property is a hidden property;
|
||||
* {@code false} otherwise.
|
||||
*/
|
||||
boolean hidden() default false;
|
||||
|
||||
/**
|
||||
* The value that indicates whether the annotated property is
|
||||
* a {@link PropertyDescriptor#isPreferred preferred} property or not.
|
||||
*
|
||||
* @return {@code true} if the annotated property is a preferred property;
|
||||
* {@code false} otherwise.
|
||||
*/
|
||||
boolean preferred() default false;
|
||||
|
||||
/**
|
||||
* The value that indicates whether the annotated property is
|
||||
* a required property or not.
|
||||
*
|
||||
* @return {@code true} if the annotated property is a required property;
|
||||
* {@code false} otherwise.
|
||||
*/
|
||||
boolean required() default false;
|
||||
|
||||
/**
|
||||
* The value that indicates whether the corresponding component
|
||||
* is repainted after the annotated property got changed or not.
|
||||
*
|
||||
* @return {@code true} if the corresponding component is repainted;
|
||||
* {@code false} otherwise.
|
||||
*/
|
||||
boolean visualUpdate() default false;
|
||||
|
||||
/**
|
||||
* The {@link PropertyDescriptor#getShortDescription short description}
|
||||
* for the {@link BeanInfo#getPropertyDescriptors descriptor}
|
||||
* of the annotated property.
|
||||
*
|
||||
* @return the property description,
|
||||
* or an empty string if the description is not set.
|
||||
*/
|
||||
String description() default "";
|
||||
|
||||
/**
|
||||
* The array of names for the public static fields
|
||||
* that contains the valid values of the annotated property.
|
||||
* These names are used to generate the {@code enumerationValues}
|
||||
* {@link java.beans.BeanDescriptor#getValue feature attribute}
|
||||
* that must contain the following items per each property value:
|
||||
* a displayable name for the property value, the actual property value,
|
||||
* and a Java code piece used for the code generator.
|
||||
*
|
||||
* @return the names of the valid values of the annotated property,
|
||||
* or an empty array if the names are not provided.
|
||||
*/
|
||||
String[] enumerationValues() default {};
|
||||
}
|
@ -22,13 +22,14 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.beans;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
import com.sun.beans.introspect.EventSetInfo;
|
||||
|
||||
/**
|
||||
* An EventSetDescriptor describes a group of events that a given Java
|
||||
* bean fires.
|
||||
@ -255,6 +256,16 @@ public class EventSetDescriptor extends FeatureDescriptor {
|
||||
setListenerType(listenerType);
|
||||
}
|
||||
|
||||
EventSetDescriptor(String base, EventSetInfo info, Method... methods) {
|
||||
setName(Introspector.decapitalize(base));
|
||||
setListenerMethods(methods);
|
||||
setAddListenerMethod(info.getAddMethod());
|
||||
setRemoveListenerMethod(info.getRemoveMethod());
|
||||
setGetListenerMethod(info.getGetMethod());
|
||||
setListenerType(info.getListenerType());
|
||||
setUnicast(info.isUnicast());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an <TT>EventSetDescriptor</TT> from scratch using
|
||||
* <TT>java.lang.reflect.MethodDescriptor</TT> and <TT>java.lang.Class</TT>
|
||||
|
@ -22,11 +22,13 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.beans;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.sun.beans.introspect.PropertyInfo;
|
||||
|
||||
/**
|
||||
* An IndexedPropertyDescriptor describes a property that acts like an
|
||||
@ -143,27 +145,21 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates <code>PropertyDescriptor</code> for the specified bean
|
||||
* with the specified name and methods to read/write the property value.
|
||||
* Creates {@code IndexedPropertyDescriptor} from the specified property info.
|
||||
*
|
||||
* @param bean the type of the target bean
|
||||
* @param base the base name of the property (the rest of the method name)
|
||||
* @param read the method used for reading the property value
|
||||
* @param write the method used for writing the property value
|
||||
* @param readIndexed the method used for reading an indexed property value
|
||||
* @param writeIndexed the method used for writing an indexed property value
|
||||
* @exception IntrospectionException if an exception occurs during introspection
|
||||
* @param entry the key-value pair,
|
||||
* where the {@code key} is the base name of the property (the rest of the method name)
|
||||
* and the {@code value} is the automatically generated property info
|
||||
* @param bound the flag indicating whether it is possible to treat this property as a bound property
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.9
|
||||
*/
|
||||
IndexedPropertyDescriptor(Class<?> bean, String base, Method read, Method write, Method readIndexed, Method writeIndexed) throws IntrospectionException {
|
||||
super(bean, base, read, write);
|
||||
|
||||
setIndexedReadMethod0(readIndexed);
|
||||
setIndexedWriteMethod0(writeIndexed);
|
||||
|
||||
// Type checking
|
||||
setIndexedPropertyType(findIndexedPropertyType(readIndexed, writeIndexed));
|
||||
IndexedPropertyDescriptor(Entry<String,PropertyInfo> entry, boolean bound) {
|
||||
super(entry, bound);
|
||||
PropertyInfo info = entry.getValue().getIndexed();
|
||||
setIndexedReadMethod0(info.getReadMethod());
|
||||
setIndexedWriteMethod0(info.getWriteMethod());
|
||||
setIndexedPropertyType(info.getPropertyType());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,32 +22,30 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.beans;
|
||||
|
||||
import com.sun.beans.TypeResolver;
|
||||
import com.sun.beans.WeakCache;
|
||||
import com.sun.beans.finder.ClassFinder;
|
||||
import com.sun.beans.finder.MethodFinder;
|
||||
import com.sun.beans.introspect.ClassInfo;
|
||||
import com.sun.beans.introspect.EventSetInfo;
|
||||
import com.sun.beans.introspect.PropertyInfo;
|
||||
|
||||
import java.awt.Component;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.EventListener;
|
||||
import java.util.EventObject;
|
||||
import java.util.List;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import sun.misc.JavaBeansIntrospectorAccess;
|
||||
import sun.misc.SharedSecrets;
|
||||
import sun.reflect.misc.ReflectUtil;
|
||||
|
||||
@ -122,7 +120,6 @@ public class Introspector {
|
||||
private BeanInfo additionalBeanInfo[];
|
||||
|
||||
private boolean propertyChangeSource = false;
|
||||
private static Class<EventListener> eventListenerType = EventListener.class;
|
||||
|
||||
// These should be removed.
|
||||
private String defaultEventName;
|
||||
@ -501,78 +498,15 @@ public class Introspector {
|
||||
addPropertyDescriptors(explicitProperties);
|
||||
|
||||
} else {
|
||||
|
||||
// Apply some reflection to the current class.
|
||||
|
||||
// First get an array of all the public methods at this level
|
||||
Method methodList[] = getPublicDeclaredMethods(beanClass);
|
||||
|
||||
// Now analyze each method.
|
||||
for (int i = 0; i < methodList.length; i++) {
|
||||
Method method = methodList[i];
|
||||
if (method == null) {
|
||||
continue;
|
||||
}
|
||||
// skip static methods.
|
||||
int mods = method.getModifiers();
|
||||
if (Modifier.isStatic(mods)) {
|
||||
continue;
|
||||
}
|
||||
String name = method.getName();
|
||||
Class<?>[] argTypes = method.getParameterTypes();
|
||||
Class<?> resultType = method.getReturnType();
|
||||
int argCount = argTypes.length;
|
||||
PropertyDescriptor pd = null;
|
||||
|
||||
if (name.length() <= 3 && !name.startsWith(IS_PREFIX)) {
|
||||
// Optimization. Don't bother with invalid propertyNames.
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
if (argCount == 0) {
|
||||
if (name.startsWith(GET_PREFIX)) {
|
||||
// Simple getter
|
||||
pd = new PropertyDescriptor(this.beanClass, name.substring(3), method, null);
|
||||
} else if (resultType == boolean.class && name.startsWith(IS_PREFIX)) {
|
||||
// Boolean getter
|
||||
pd = new PropertyDescriptor(this.beanClass, name.substring(2), method, null);
|
||||
}
|
||||
} else if (argCount == 1) {
|
||||
if (int.class.equals(argTypes[0]) && name.startsWith(GET_PREFIX)) {
|
||||
pd = new IndexedPropertyDescriptor(this.beanClass, name.substring(3), null, null, method, null);
|
||||
} else if (void.class.equals(resultType) && name.startsWith(SET_PREFIX)) {
|
||||
// Simple setter
|
||||
pd = new PropertyDescriptor(this.beanClass, name.substring(3), null, method);
|
||||
if (throwsException(method, PropertyVetoException.class)) {
|
||||
pd.setConstrained(true);
|
||||
}
|
||||
}
|
||||
} else if (argCount == 2) {
|
||||
if (void.class.equals(resultType) && int.class.equals(argTypes[0]) && name.startsWith(SET_PREFIX)) {
|
||||
pd = new IndexedPropertyDescriptor(this.beanClass, name.substring(3), null, null, null, method);
|
||||
if (throwsException(method, PropertyVetoException.class)) {
|
||||
pd.setConstrained(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IntrospectionException ex) {
|
||||
// This happens if a PropertyDescriptor or IndexedPropertyDescriptor
|
||||
// constructor fins that the method violates details of the deisgn
|
||||
// pattern, e.g. by having an empty name, or a getter returning
|
||||
// void , or whatever.
|
||||
pd = null;
|
||||
}
|
||||
|
||||
if (pd != null) {
|
||||
// If this class or one of its base classes is a PropertyChange
|
||||
// source, then we assume that any properties we discover are "bound".
|
||||
if (propertyChangeSource) {
|
||||
pd.setBound(true);
|
||||
}
|
||||
addPropertyDescriptor(pd);
|
||||
}
|
||||
for (Map.Entry<String,PropertyInfo> entry : ClassInfo.get(this.beanClass).getProperties().entrySet()) {
|
||||
addPropertyDescriptor(null != entry.getValue().getIndexed()
|
||||
? new IndexedPropertyDescriptor(entry, this.propertyChangeSource)
|
||||
: new PropertyDescriptor(entry, this.propertyChangeSource));
|
||||
}
|
||||
JavaBean annotation = this.beanClass.getAnnotation(JavaBean.class);
|
||||
if ((annotation != null) && !annotation.defaultProperty().isEmpty()) {
|
||||
this.defaultPropertyName = annotation.defaultProperty();
|
||||
}
|
||||
}
|
||||
processPropertyDescriptors();
|
||||
@ -589,7 +523,6 @@ public class Introspector {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1003,143 +936,24 @@ public class Introspector {
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// Apply some reflection to the current class.
|
||||
|
||||
// Get an array of all the public beans methods at this level
|
||||
Method methodList[] = getPublicDeclaredMethods(beanClass);
|
||||
|
||||
// Find all suitable "add", "remove" and "get" Listener methods
|
||||
// The name of the listener type is the key for these hashtables
|
||||
// i.e, ActionListener
|
||||
Map<String, Method> adds = null;
|
||||
Map<String, Method> removes = null;
|
||||
Map<String, Method> gets = null;
|
||||
|
||||
for (int i = 0; i < methodList.length; i++) {
|
||||
Method method = methodList[i];
|
||||
if (method == null) {
|
||||
continue;
|
||||
}
|
||||
// skip static methods.
|
||||
int mods = method.getModifiers();
|
||||
if (Modifier.isStatic(mods)) {
|
||||
continue;
|
||||
}
|
||||
String name = method.getName();
|
||||
// Optimization avoid getParameterTypes
|
||||
if (!name.startsWith(ADD_PREFIX) && !name.startsWith(REMOVE_PREFIX)
|
||||
&& !name.startsWith(GET_PREFIX)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (name.startsWith(ADD_PREFIX)) {
|
||||
Class<?> returnType = method.getReturnType();
|
||||
if (returnType == void.class) {
|
||||
Type[] parameterTypes = method.getGenericParameterTypes();
|
||||
if (parameterTypes.length == 1) {
|
||||
Class<?> type = TypeResolver.erase(TypeResolver.resolveInClass(beanClass, parameterTypes[0]));
|
||||
if (Introspector.isSubclass(type, eventListenerType)) {
|
||||
String listenerName = name.substring(3);
|
||||
if (listenerName.length() > 0 &&
|
||||
type.getName().endsWith(listenerName)) {
|
||||
if (adds == null) {
|
||||
adds = new HashMap<>();
|
||||
}
|
||||
adds.put(listenerName, method);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (name.startsWith(REMOVE_PREFIX)) {
|
||||
Class<?> returnType = method.getReturnType();
|
||||
if (returnType == void.class) {
|
||||
Type[] parameterTypes = method.getGenericParameterTypes();
|
||||
if (parameterTypes.length == 1) {
|
||||
Class<?> type = TypeResolver.erase(TypeResolver.resolveInClass(beanClass, parameterTypes[0]));
|
||||
if (Introspector.isSubclass(type, eventListenerType)) {
|
||||
String listenerName = name.substring(6);
|
||||
if (listenerName.length() > 0 &&
|
||||
type.getName().endsWith(listenerName)) {
|
||||
if (removes == null) {
|
||||
removes = new HashMap<>();
|
||||
}
|
||||
removes.put(listenerName, method);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (name.startsWith(GET_PREFIX)) {
|
||||
Class<?>[] parameterTypes = method.getParameterTypes();
|
||||
if (parameterTypes.length == 0) {
|
||||
Class<?> returnType = FeatureDescriptor.getReturnType(beanClass, method);
|
||||
if (returnType.isArray()) {
|
||||
Class<?> type = returnType.getComponentType();
|
||||
if (Introspector.isSubclass(type, eventListenerType)) {
|
||||
String listenerName = name.substring(3, name.length() - 1);
|
||||
if (listenerName.length() > 0 &&
|
||||
type.getName().endsWith(listenerName)) {
|
||||
if (gets == null) {
|
||||
gets = new HashMap<>();
|
||||
}
|
||||
gets.put(listenerName, method);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (adds != null && removes != null) {
|
||||
// Now look for matching addFooListener+removeFooListener pairs.
|
||||
// Bonus if there is a matching getFooListeners method as well.
|
||||
Iterator<String> keys = adds.keySet().iterator();
|
||||
while (keys.hasNext()) {
|
||||
String listenerName = keys.next();
|
||||
// Skip any "add" which doesn't have a matching "remove" or
|
||||
// a listener name that doesn't end with Listener
|
||||
if (removes.get(listenerName) == null || !listenerName.endsWith("Listener")) {
|
||||
continue;
|
||||
}
|
||||
String eventName = decapitalize(listenerName.substring(0, listenerName.length()-8));
|
||||
Method addMethod = adds.get(listenerName);
|
||||
Method removeMethod = removes.get(listenerName);
|
||||
Method getMethod = null;
|
||||
if (gets != null) {
|
||||
getMethod = gets.get(listenerName);
|
||||
}
|
||||
Class<?> argType = FeatureDescriptor.getParameterTypes(beanClass, addMethod)[0];
|
||||
|
||||
for (Map.Entry<String,EventSetInfo> entry : ClassInfo.get(this.beanClass).getEventSets().entrySet()) {
|
||||
// generate a list of Method objects for each of the target methods:
|
||||
Method allMethods[] = getPublicDeclaredMethods(argType);
|
||||
List<Method> validMethods = new ArrayList<>(allMethods.length);
|
||||
for (int i = 0; i < allMethods.length; i++) {
|
||||
if (allMethods[i] == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isEventHandler(allMethods[i])) {
|
||||
validMethods.add(allMethods[i]);
|
||||
}
|
||||
List<Method> methods = new ArrayList<>();
|
||||
for (Method method : ClassInfo.get(entry.getValue().getListenerType()).getMethods()) {
|
||||
if (isEventHandler(method)) {
|
||||
methods.add(method);
|
||||
}
|
||||
Method[] methods = validMethods.toArray(new Method[validMethods.size()]);
|
||||
|
||||
EventSetDescriptor esd = new EventSetDescriptor(eventName, argType,
|
||||
methods, addMethod,
|
||||
removeMethod,
|
||||
getMethod);
|
||||
|
||||
// If the adder method throws the TooManyListenersException then it
|
||||
// is a Unicast event source.
|
||||
if (throwsException(addMethod,
|
||||
java.util.TooManyListenersException.class)) {
|
||||
esd.setUnicast(true);
|
||||
}
|
||||
addEvent(esd);
|
||||
}
|
||||
} // if (adds != null ...
|
||||
addEvent(new EventSetDescriptor(
|
||||
entry.getKey(),
|
||||
entry.getValue(),
|
||||
methods.toArray(new Method[methods.size()])));
|
||||
}
|
||||
JavaBean annotation = this.beanClass.getAnnotation(JavaBean.class);
|
||||
if ((annotation != null) && !annotation.defaultEventSet().isEmpty()) {
|
||||
this.defaultEventName = annotation.defaultEventSet();
|
||||
}
|
||||
}
|
||||
EventSetDescriptor[] result;
|
||||
if (events.size() == 0) {
|
||||
@ -1148,7 +962,6 @@ public class Introspector {
|
||||
// Allocate and populate the result array.
|
||||
result = new EventSetDescriptor[events.size()];
|
||||
result = events.values().toArray(result);
|
||||
|
||||
// Set the default index.
|
||||
if (defaultEventName != null) {
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
@ -1215,20 +1028,9 @@ public class Introspector {
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// Apply some reflection to the current class.
|
||||
|
||||
// First get an array of all the beans methods at this level
|
||||
Method methodList[] = getPublicDeclaredMethods(beanClass);
|
||||
|
||||
// Now analyze each method.
|
||||
for (int i = 0; i < methodList.length; i++) {
|
||||
Method method = methodList[i];
|
||||
if (method == null) {
|
||||
continue;
|
||||
}
|
||||
MethodDescriptor md = new MethodDescriptor(method);
|
||||
addMethod(md);
|
||||
for (Method method : ClassInfo.get(this.beanClass).getMethods()) {
|
||||
addMethod(new MethodDescriptor(method));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1346,44 +1148,6 @@ public class Introspector {
|
||||
return isSubclass(TypeResolver.erase(TypeResolver.resolveInClass(beanClass, argTypes[0])), EventObject.class);
|
||||
}
|
||||
|
||||
/*
|
||||
* Internal method to return *public* methods within a class.
|
||||
*/
|
||||
private static Method[] getPublicDeclaredMethods(Class<?> clz) {
|
||||
// Looking up Class.getDeclaredMethods is relatively expensive,
|
||||
// so we cache the results.
|
||||
if (!ReflectUtil.isPackageAccessible(clz)) {
|
||||
return new Method[0];
|
||||
}
|
||||
synchronized (declaredMethodCache) {
|
||||
Method[] result = declaredMethodCache.get(clz);
|
||||
if (result == null) {
|
||||
result = clz.getMethods();
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
Method method = result[i];
|
||||
if (!method.getDeclaringClass().equals(clz)) {
|
||||
result[i] = null; // ignore methods declared elsewhere
|
||||
}
|
||||
else {
|
||||
try {
|
||||
method = MethodFinder.findAccessibleMethod(method);
|
||||
Class<?> type = method.getDeclaringClass();
|
||||
result[i] = type.equals(clz) || type.isInterface()
|
||||
? method
|
||||
: null; // ignore methods from superclasses
|
||||
}
|
||||
catch (NoSuchMethodException exception) {
|
||||
// commented out because of 6976577
|
||||
// result[i] = null; // ignore inaccessible methods
|
||||
}
|
||||
}
|
||||
}
|
||||
declaredMethodCache.put(clz, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//======================================================================
|
||||
// Package private support methods.
|
||||
//======================================================================
|
||||
@ -1396,17 +1160,8 @@ public class Introspector {
|
||||
int argCount, Class<?> args[]) {
|
||||
// For overriden methods we need to find the most derived version.
|
||||
// So we start with the given class and walk up the superclass chain.
|
||||
|
||||
Method method = null;
|
||||
|
||||
for (Class<?> cl = start; cl != null; cl = cl.getSuperclass()) {
|
||||
Method methods[] = getPublicDeclaredMethods(cl);
|
||||
for (int i = 0; i < methods.length; i++) {
|
||||
method = methods[i];
|
||||
if (method == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (Method method : ClassInfo.get(cl).getMethods()) {
|
||||
// make sure method signature matches.
|
||||
if (method.getName().equals(methodName)) {
|
||||
Type[] params = method.getGenericParameterTypes();
|
||||
@ -1430,8 +1185,6 @@ public class Introspector {
|
||||
}
|
||||
}
|
||||
}
|
||||
method = null;
|
||||
|
||||
// Now check any inherited interfaces. This is necessary both when
|
||||
// the argument class is itself an interface, and when the argument
|
||||
// class is an abstract class.
|
||||
@ -1440,12 +1193,12 @@ public class Introspector {
|
||||
// Note: The original implementation had both methods calling
|
||||
// the 3 arg method. This is preserved but perhaps it should
|
||||
// pass the args array instead of null.
|
||||
method = internalFindMethod(ifcs[i], methodName, argCount, null);
|
||||
Method method = internalFindMethod(ifcs[i], methodName, argCount, null);
|
||||
if (method != null) {
|
||||
break;
|
||||
return method;
|
||||
}
|
||||
}
|
||||
return method;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1507,19 +1260,6 @@ public class Introspector {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true iff the given method throws the given exception.
|
||||
*/
|
||||
private boolean throwsException(Method method, Class<?> exception) {
|
||||
Class<?>[] exs = method.getExceptionTypes();
|
||||
for (int i = 0; i < exs.length; i++) {
|
||||
if (exs[i] == exception) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to create an instance of a named class.
|
||||
* First try the classloader of "sibling", then try the system
|
||||
|
89
jdk/src/share/classes/java/beans/JavaBean.java
Normal file
89
jdk/src/share/classes/java/beans/JavaBean.java
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 java.beans;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* An annotation used to specify some class-related information
|
||||
* for the automatically generated {@link BeanInfo} classes.
|
||||
* This annotation is not used if the annotated class
|
||||
* has a corresponding user-defined {@code BeanInfo} class,
|
||||
* which does not imply the automatic analysis.
|
||||
*
|
||||
* @see BeanInfo#getBeanDescriptor
|
||||
* @since 1.9
|
||||
*
|
||||
* @author Sergey A. Malenkov
|
||||
*/
|
||||
@Documented
|
||||
@Target({TYPE})
|
||||
@Retention(RUNTIME)
|
||||
public @interface JavaBean {
|
||||
/**
|
||||
* The {@link BeanDescriptor#getShortDescription short description}
|
||||
* for the {@link BeanInfo#getBeanDescriptor bean descriptor}
|
||||
* of the annotated class.
|
||||
*
|
||||
* @return the bean description,
|
||||
* or an empty string if the description is not set.
|
||||
*/
|
||||
String description() default "";
|
||||
|
||||
/**
|
||||
* The name of the default property is used to calculate its
|
||||
* {@link BeanInfo#getDefaultPropertyIndex index} in the
|
||||
* {@link BeanInfo#getPropertyDescriptors array} of properties
|
||||
* defined in the annotated class. If the name is not set or
|
||||
* the annotated class does not define a property
|
||||
* with the specified name, the default property index
|
||||
* will be calculated automatically by the
|
||||
* {@link Introspector} depending on its state.
|
||||
*
|
||||
* @return the name of the default property,
|
||||
* or an empty string if the name is not set.
|
||||
*/
|
||||
String defaultProperty() default "";
|
||||
|
||||
/**
|
||||
* The name of the default event set is used to calculate its
|
||||
* {@link BeanInfo#getDefaultEventIndex index} in the
|
||||
* {@link BeanInfo#getEventSetDescriptors array} of event sets
|
||||
* defined in the annotated class. If the name is not set or
|
||||
* the annotated class does not define an event set
|
||||
* with the specified name, the default event set index
|
||||
* will be calculated automatically by the
|
||||
* {@link Introspector} depending on its state.
|
||||
*
|
||||
* @return the name of the default event set,
|
||||
* or an empty string if the name is not set.
|
||||
*/
|
||||
String defaultEventSet() default "";
|
||||
}
|
@ -22,12 +22,14 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.beans;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.sun.beans.introspect.PropertyInfo;
|
||||
|
||||
/**
|
||||
* A PropertyDescriptor describes one property that a Java Bean
|
||||
@ -140,25 +142,47 @@ public class PropertyDescriptor extends FeatureDescriptor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates <code>PropertyDescriptor</code> for the specified bean
|
||||
* with the specified name and methods to read/write the property value.
|
||||
* Creates {@code PropertyDescriptor} from the specified property info.
|
||||
*
|
||||
* @param bean the type of the target bean
|
||||
* @param base the base name of the property (the rest of the method name)
|
||||
* @param read the method used for reading the property value
|
||||
* @param write the method used for writing the property value
|
||||
* @exception IntrospectionException if an exception occurs during introspection
|
||||
* @param entry the pair of values,
|
||||
* where the {@code key} is the base name of the property (the rest of the method name)
|
||||
* and the {@code value} is the automatically generated property info
|
||||
* @param bound the flag indicating whether it is possible to treat this property as a bound property
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.9
|
||||
*/
|
||||
PropertyDescriptor(Class<?> bean, String base, Method read, Method write) throws IntrospectionException {
|
||||
if (bean == null) {
|
||||
throw new IntrospectionException("Target Bean class is null");
|
||||
}
|
||||
setClass0(bean);
|
||||
PropertyDescriptor(Entry<String,PropertyInfo> entry, boolean bound) {
|
||||
String base = entry.getKey();
|
||||
PropertyInfo info = entry.getValue();
|
||||
setName(Introspector.decapitalize(base));
|
||||
setReadMethod(read);
|
||||
setWriteMethod(write);
|
||||
setReadMethod0(info.getReadMethod());
|
||||
setWriteMethod0(info.getWriteMethod());
|
||||
setPropertyType(info.getPropertyType());
|
||||
setConstrained(info.isConstrained());
|
||||
setBound(bound && info.is(PropertyInfo.Name.bound));
|
||||
if (info.is(PropertyInfo.Name.expert)) {
|
||||
setValue(PropertyInfo.Name.expert.name(), Boolean.TRUE); // compatibility
|
||||
setExpert(true);
|
||||
}
|
||||
if (info.is(PropertyInfo.Name.hidden)) {
|
||||
setValue(PropertyInfo.Name.hidden.name(), Boolean.TRUE); // compatibility
|
||||
setHidden(true);
|
||||
}
|
||||
if (info.is(PropertyInfo.Name.preferred)) {
|
||||
setPreferred(true);
|
||||
}
|
||||
Object visual = info.get(PropertyInfo.Name.visualUpdate);
|
||||
if (visual != null) {
|
||||
setValue(PropertyInfo.Name.visualUpdate.name(), visual);
|
||||
}
|
||||
Object description = info.get(PropertyInfo.Name.description);
|
||||
if (description != null) {
|
||||
setShortDescription(description.toString());
|
||||
}
|
||||
Object values = info.get(PropertyInfo.Name.enumerationValues);
|
||||
if (values != null) {
|
||||
setValue(PropertyInfo.Name.enumerationValues.name(), values);
|
||||
}
|
||||
this.baseName = base;
|
||||
}
|
||||
|
||||
@ -249,13 +273,17 @@ public class PropertyDescriptor extends FeatureDescriptor {
|
||||
*/
|
||||
public synchronized void setReadMethod(Method readMethod)
|
||||
throws IntrospectionException {
|
||||
// The property type is determined by the read method.
|
||||
setPropertyType(findPropertyType(readMethod, this.writeMethodRef.get()));
|
||||
setReadMethod0(readMethod);
|
||||
}
|
||||
|
||||
private void setReadMethod0(Method readMethod) {
|
||||
this.readMethodRef.set(readMethod);
|
||||
if (readMethod == null) {
|
||||
readMethodName = null;
|
||||
return;
|
||||
}
|
||||
// The property type is determined by the read method.
|
||||
setPropertyType(findPropertyType(readMethod, this.writeMethodRef.get()));
|
||||
setClass0(readMethod.getDeclaringClass());
|
||||
|
||||
readMethodName = readMethod.getName();
|
||||
@ -320,13 +348,17 @@ public class PropertyDescriptor extends FeatureDescriptor {
|
||||
*/
|
||||
public synchronized void setWriteMethod(Method writeMethod)
|
||||
throws IntrospectionException {
|
||||
// Set the property type - which validates the method
|
||||
setPropertyType(findPropertyType(getReadMethod(), writeMethod));
|
||||
setWriteMethod0(writeMethod);
|
||||
}
|
||||
|
||||
private void setWriteMethod0(Method writeMethod) {
|
||||
this.writeMethodRef.set(writeMethod);
|
||||
if (writeMethod == null) {
|
||||
writeMethodName = null;
|
||||
return;
|
||||
}
|
||||
// Set the property type - which validates the method
|
||||
setPropertyType(findPropertyType(getReadMethod(), writeMethod));
|
||||
setClass0(writeMethod.getDeclaringClass());
|
||||
|
||||
writeMethodName = writeMethod.getName();
|
||||
|
@ -134,10 +134,11 @@ public final class Class<T> implements java.io.Serializable,
|
||||
* This constructor is not used and prevents the default constructor being
|
||||
* generated.
|
||||
*/
|
||||
private Class(ClassLoader loader) {
|
||||
private Class(ClassLoader loader, Class<?> arrayComponentType) {
|
||||
// Initialize final field for classLoader. The initialization value of non-null
|
||||
// prevents future JIT optimizations from assuming this final field is null.
|
||||
classLoader = loader;
|
||||
componentType = arrayComponentType;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -917,7 +918,16 @@ public final class Class<T> implements java.io.Serializable,
|
||||
* @see java.lang.reflect.Array
|
||||
* @since 1.1
|
||||
*/
|
||||
public native Class<?> getComponentType();
|
||||
public Class<?> getComponentType() {
|
||||
// Only return for array types. Storage may be reused for Class for instance types.
|
||||
if (isArray()) {
|
||||
return componentType;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private final Class<?> componentType;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -147,7 +147,7 @@ final class ConditionalSpecialCasing {
|
||||
}
|
||||
|
||||
private static char[] lookUpTable(String src, int index, Locale locale, boolean bLowerCasing) {
|
||||
HashSet<Entry> set = entryTable.get(new Integer(src.codePointAt(index)));
|
||||
HashSet<Entry> set = entryTable.get(src.codePointAt(index));
|
||||
char[] ret = null;
|
||||
|
||||
if (set != null) {
|
||||
|
@ -957,6 +957,7 @@ public final class ProcessBuilder
|
||||
* <li>The operating system program file was not found.
|
||||
* <li>Access to the program file was denied.
|
||||
* <li>The working directory does not exist.
|
||||
* <li>Invalid character in command argument, such as NUL.
|
||||
* </ul>
|
||||
*
|
||||
* <p>In such cases an exception will be thrown. The exact nature
|
||||
@ -1019,6 +1020,12 @@ public final class ProcessBuilder
|
||||
|
||||
String dir = directory == null ? null : directory.toString();
|
||||
|
||||
for (int i = 1; i < cmdarray.length; i++) {
|
||||
if (cmdarray[i].indexOf('\u0000') >= 0) {
|
||||
throw new IOException("invalid null character in command");
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
return ProcessImpl.start(cmdarray,
|
||||
environment,
|
||||
|
@ -1505,6 +1505,10 @@ return mh1;
|
||||
// that is *not* the bytecode behavior.
|
||||
mods ^= Modifier.PROTECTED | Modifier.PUBLIC;
|
||||
}
|
||||
if (Modifier.isProtected(mods) && refKind == REF_newInvokeSpecial) {
|
||||
// cannot "new" a protected ctor in a different package
|
||||
mods ^= Modifier.PROTECTED;
|
||||
}
|
||||
if (Modifier.isFinal(mods) &&
|
||||
MethodHandleNatives.refKindIsSetter(refKind))
|
||||
throw m.makeAccessException("unexpected set of a final field", this);
|
||||
|
@ -362,12 +362,13 @@ public class Proxy implements java.io.Serializable {
|
||||
Class<?>... interfaces)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
final Class<?>[] intfs = interfaces.clone();
|
||||
final SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
checkProxyAccess(Reflection.getCallerClass(), loader, interfaces);
|
||||
checkProxyAccess(Reflection.getCallerClass(), loader, intfs);
|
||||
}
|
||||
|
||||
return getProxyClass0(loader, interfaces);
|
||||
return getProxyClass0(loader, intfs);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -706,15 +707,16 @@ public class Proxy implements java.io.Serializable {
|
||||
{
|
||||
Objects.requireNonNull(h);
|
||||
|
||||
final Class<?>[] intfs = interfaces.clone();
|
||||
final SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
checkProxyAccess(Reflection.getCallerClass(), loader, interfaces);
|
||||
checkProxyAccess(Reflection.getCallerClass(), loader, intfs);
|
||||
}
|
||||
|
||||
/*
|
||||
* Look up or generate the designated proxy class.
|
||||
*/
|
||||
Class<?> cl = getProxyClass0(loader, interfaces);
|
||||
Class<?> cl = getProxyClass0(loader, intfs);
|
||||
|
||||
/*
|
||||
* Invoke its constructor with the designated invocation handler.
|
||||
|
@ -322,13 +322,13 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
|
||||
|
||||
switch (optID) {
|
||||
case SO_TIMEOUT:
|
||||
result = new Integer(timeout);
|
||||
result = timeout;
|
||||
break;
|
||||
|
||||
case IP_TOS:
|
||||
result = socketGetOption(optID);
|
||||
if ( ((Integer)result).intValue() == -1) {
|
||||
result = new Integer(trafficClass);
|
||||
result = trafficClass;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -279,7 +279,7 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
|
||||
throw new SocketException("Socket Closed");
|
||||
}
|
||||
if (opt == SO_TIMEOUT) {
|
||||
return new Integer(timeout);
|
||||
return timeout;
|
||||
}
|
||||
int ret = 0;
|
||||
/*
|
||||
@ -299,7 +299,7 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
|
||||
return Boolean.valueOf(ret != -1);
|
||||
case SO_LINGER:
|
||||
ret = socketGetOption(opt, null);
|
||||
return (ret == -1) ? Boolean.FALSE: (Object)(new Integer(ret));
|
||||
return (ret == -1) ? Boolean.FALSE: (Object)(ret);
|
||||
case SO_REUSEADDR:
|
||||
ret = socketGetOption(opt, null);
|
||||
return Boolean.valueOf(ret != -1);
|
||||
@ -310,13 +310,13 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
|
||||
case SO_SNDBUF:
|
||||
case SO_RCVBUF:
|
||||
ret = socketGetOption(opt, null);
|
||||
return new Integer(ret);
|
||||
return ret;
|
||||
case IP_TOS:
|
||||
ret = socketGetOption(opt, null);
|
||||
if (ret == -1) { // ipv6 tos
|
||||
return new Integer(trafficClass);
|
||||
return trafficClass;
|
||||
} else {
|
||||
return new Integer(ret);
|
||||
return ret;
|
||||
}
|
||||
case SO_KEEPALIVE:
|
||||
ret = socketGetOption(opt, null);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user