mirror of
https://github.com/darlinghq/darling-openjdk.git
synced 2024-11-27 06:10:37 +00:00
8222799: java.beans.Introspector uses an obsolete methods cache
Reviewed-by: prr
This commit is contained in:
parent
4ee5f65691
commit
921b46738e
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2019, 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
|
||||
@ -22,32 +22,29 @@
|
||||
* 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.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.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EventObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.EventObject;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import com.sun.beans.TypeResolver;
|
||||
import com.sun.beans.finder.ClassFinder;
|
||||
import com.sun.beans.introspect.ClassInfo;
|
||||
import com.sun.beans.introspect.EventSetInfo;
|
||||
import com.sun.beans.introspect.PropertyInfo;
|
||||
import jdk.internal.access.JavaBeansAccess;
|
||||
import jdk.internal.access.SharedSecrets;
|
||||
import sun.reflect.misc.ReflectUtil;
|
||||
@ -114,9 +111,6 @@ public class Introspector {
|
||||
*/
|
||||
public static final int IGNORE_ALL_BEANINFO = 3;
|
||||
|
||||
// Static Caches to speed up introspection.
|
||||
private static final WeakCache<Class<?>, Method[]> declaredMethodCache = new WeakCache<>();
|
||||
|
||||
private Class<?> beanClass;
|
||||
private BeanInfo explicitBeanInfo;
|
||||
private BeanInfo superBeanInfo;
|
||||
@ -196,15 +190,10 @@ public class Introspector {
|
||||
return (new Introspector(beanClass, null, USE_ALL_BEANINFO)).getBeanInfo();
|
||||
}
|
||||
ThreadGroupContext context = ThreadGroupContext.getContext();
|
||||
BeanInfo beanInfo;
|
||||
synchronized (declaredMethodCache) {
|
||||
beanInfo = context.getBeanInfo(beanClass);
|
||||
}
|
||||
BeanInfo beanInfo = context.getBeanInfo(beanClass);
|
||||
if (beanInfo == null) {
|
||||
beanInfo = new Introspector(beanClass, null, USE_ALL_BEANINFO).getBeanInfo();
|
||||
synchronized (declaredMethodCache) {
|
||||
context.putBeanInfo(beanClass, beanInfo);
|
||||
}
|
||||
context.putBeanInfo(beanClass, beanInfo);
|
||||
}
|
||||
return beanInfo;
|
||||
}
|
||||
@ -373,12 +362,8 @@ public class Introspector {
|
||||
*
|
||||
* @since 1.2
|
||||
*/
|
||||
|
||||
public static void flushCaches() {
|
||||
synchronized (declaredMethodCache) {
|
||||
ThreadGroupContext.getContext().clearBeanInfoCache();
|
||||
declaredMethodCache.clear();
|
||||
}
|
||||
ThreadGroupContext.getContext().clearBeanInfoCache();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -401,10 +386,7 @@ public class Introspector {
|
||||
if (clz == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
synchronized (declaredMethodCache) {
|
||||
ThreadGroupContext.getContext().removeBeanInfo(clz);
|
||||
declaredMethodCache.put(clz, null);
|
||||
}
|
||||
ThreadGroupContext.getContext().removeBeanInfo(clz);
|
||||
}
|
||||
|
||||
//======================================================================
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2019, 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
|
||||
@ -88,26 +88,26 @@ final class ThreadGroupContext {
|
||||
}
|
||||
|
||||
|
||||
BeanInfo getBeanInfo(Class<?> type) {
|
||||
synchronized BeanInfo getBeanInfo(Class<?> type) {
|
||||
return (this.beanInfoCache != null)
|
||||
? this.beanInfoCache.get(type)
|
||||
: null;
|
||||
}
|
||||
|
||||
BeanInfo putBeanInfo(Class<?> type, BeanInfo info) {
|
||||
synchronized BeanInfo putBeanInfo(Class<?> type, BeanInfo info) {
|
||||
if (this.beanInfoCache == null) {
|
||||
this.beanInfoCache = new WeakHashMap<>();
|
||||
}
|
||||
return this.beanInfoCache.put(type, info);
|
||||
}
|
||||
|
||||
void removeBeanInfo(Class<?> type) {
|
||||
synchronized void removeBeanInfo(Class<?> type) {
|
||||
if (this.beanInfoCache != null) {
|
||||
this.beanInfoCache.remove(type);
|
||||
}
|
||||
}
|
||||
|
||||
void clearBeanInfoCache() {
|
||||
synchronized void clearBeanInfoCache() {
|
||||
if (this.beanInfoCache != null) {
|
||||
this.beanInfoCache.clear();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user