reduce dependency on CGLIB

GitOrigin-RevId: 5c59ba6aac4113d14c50260c4a58bc7d45249338
This commit is contained in:
Vladimir Krivosheev
2024-04-10 07:22:10 +02:00
committed by intellij-monorepo-bot
parent d4266f30ab
commit f8b4ecb14f
19 changed files with 78 additions and 66 deletions

View File

@@ -1,18 +0,0 @@
<component name="libraryTable">
<library name="CGLIB" type="repository">
<properties maven-id="cglib:cglib-nodep:3.3.0">
<verification>
<artifact url="file://$MAVEN_REPOSITORY$/cglib/cglib-nodep/3.3.0/cglib-nodep-3.3.0.jar">
<sha256sum>3366d2c88fb576e486d830f521184e8f1839f8c15dcd2151a3f6e1f62b0b37a0</sha256sum>
</artifact>
</verification>
</properties>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/cglib/cglib-nodep/3.3.0/cglib-nodep-3.3.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/cglib/cglib-nodep/3.3.0/cglib-nodep-3.3.0-sources.jar!/" />
</SOURCES>
</library>
</component>

1
.idea/modules.xml generated
View File

@@ -855,6 +855,7 @@
<module fileurl="file://$PROJECT_DIR$/plugins/kotlin/intellij.kotlin.plugin.community.main.iml" filepath="$PROJECT_DIR$/plugins/kotlin/intellij.kotlin.plugin.community.main.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/laf/macos/intellij.laf.macos.iml" filepath="$PROJECT_DIR$/plugins/laf/macos/intellij.laf.macos.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/laf/win10/intellij.laf.win10.iml" filepath="$PROJECT_DIR$/plugins/laf/win10/intellij.laf.win10.iml" />
<module fileurl="file://$PROJECT_DIR$/platform/libraries/cglib/intellij.libraries.cglib.iml" filepath="$PROJECT_DIR$/platform/libraries/cglib/intellij.libraries.cglib.iml" />
<module fileurl="file://$PROJECT_DIR$/platform/libraries/grpc/intellij.libraries.grpc.iml" filepath="$PROJECT_DIR$/platform/libraries/grpc/intellij.libraries.grpc.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/lombok/intellij.lombok.iml" filepath="$PROJECT_DIR$/plugins/lombok/intellij.lombok.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/lombok/generated/intellij.lombok.generated.iml" filepath="$PROJECT_DIR$/plugins/lombok/generated/intellij.lombok.generated.iml" />

View File

@@ -261,7 +261,7 @@ object CommunityLibraryLicenses {
url = "https://github.com/ben-manes/caffeine")
.apache("https://github.com/ben-manes/caffeine/blob/master/LICENSE")
.suppliedByPersons("Ben Manes"),
LibraryLicense(name = "CGLib", libraryName = "CGLIB", url = "https://github.com/cglib/cglib/")
LibraryLicense(name = "CGLib", libraryName = "cglib", url = "https://github.com/cglib/cglib/")
.apache("https://github.com/cglib/cglib/blob/master/LICENSE")
.suppliedByPersons("cglib project contributors"),
LibraryLicense(name = "classgraph", libraryName = "classgraph", license = "codehaus",

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library" exported="">
<library name="cglib" type="repository">
<properties include-transitive-deps="false" maven-id="cglib:cglib-nodep:3.3.0">
<verification>
<artifact url="file://$MAVEN_REPOSITORY$/cglib/cglib-nodep/3.3.0/cglib-nodep-3.3.0.jar">
<sha256sum>3366d2c88fb576e486d830f521184e8f1839f8c15dcd2151a3f6e1f62b0b37a0</sha256sum>
</artifact>
</verification>
</properties>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/cglib/cglib-nodep/3.3.0/cglib-nodep-3.3.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/cglib/cglib-nodep/3.3.0/cglib-nodep-3.3.0-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module" module-name="intellij.platform.util.base" />
<orderEntry type="module" module-name="intellij.platform.util.rt" />
<orderEntry type="module" module-name="intellij.platform.util" />
<orderEntry type="module" module-name="intellij.platform.core" />
<orderEntry type="module" module-name="intellij.platform.core.impl" />
<orderEntry type="library" name="fastutil-min" level="project" />
<orderEntry type="module" module-name="intellij.platform.util.classLoader" />
</component>
</module>

View File

@@ -0,0 +1 @@
Not yet a product module as XML has not yet been extracted from the core.

View File

@@ -15,7 +15,6 @@
*/
package net.sf.cglib.core;
import com.intellij.reference.SoftReference;
import net.sf.cglib.asm.$ClassReader;
import java.lang.ref.Reference;
@@ -201,7 +200,7 @@ implements ClassGenerator
source.cache.put(loader, cache2);
} else if (useCache) {
Reference ref = (Reference)cache2.get(key);
gen = (Class) SoftReference.dereference(ref);
gen = ref == null ? null : (Class) ref.get();
}
if (gen == null) {
AbstractClassGenerator save = CURRENT.get();

View File

@@ -579,7 +579,7 @@ public final class AdvancedEnhancer extends AbstractClassGenerator
*/
private static void filterConstructors(Class<?> sc, List<Constructor<?>> constructors) {
CollectionUtils.filter(constructors, new VisibilityPredicate(sc, true));
if (constructors.size() == 0) {
if (constructors.isEmpty()) {
throw new IllegalArgumentException("No visible constructors in " + sc);
}
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package net.sf.cglib.proxy;
import com.intellij.openapi.progress.ProcessCanceledException;

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package net.sf.cglib.proxy;
import net.sf.cglib.core.Block;

View File

@@ -35,7 +35,6 @@
<orderEntry type="module" module-name="intellij.platform.ide" exported="" />
<orderEntry type="library" name="commons-codec" level="project" />
<orderEntry type="library" name="OroMatcher" level="project" />
<orderEntry type="library" name="CGLIB" level="project" />
<orderEntry type="module" module-name="intellij.platform.lang" />
<orderEntry type="library" name="jna" level="project" />
<orderEntry type="library" name="winp" level="project" />

View File

@@ -80,7 +80,6 @@ import com.intellij.util.SystemProperties
import com.intellij.util.containers.WeakList
import com.intellij.util.messages.impl.MessageBusEx
import com.intellij.util.ref.GCWatcher
import net.sf.cglib.core.ClassNameReader
import java.awt.KeyboardFocusManager
import java.awt.Window
import java.nio.channels.FileChannel
@@ -556,7 +555,6 @@ object DynamicPlugins {
ThrowableInterner.clearInternedBacktraces()
IdeaLogger.ourErrorsOccurred = null // ensure we don't have references to plugin classes in exception stacktraces
clearTemporaryLostComponent()
clearCglibStopBacktrace()
if (app.isUnitTestMode && pluginDescriptor.pluginClassLoader !is PluginClassLoader) {
classLoaderUnloaded = true
@@ -948,18 +946,6 @@ private fun hideTooltip() {
}
}
private fun clearCglibStopBacktrace() {
val field = ReflectionUtil.getDeclaredField(ClassNameReader::class.java, "EARLY_EXIT")
if (field != null) {
try {
ThrowableInterner.clearBacktrace((field[null] as Throwable))
}
catch (e: Throwable) {
LOG.info(e)
}
}
}
private fun clearNewFocusOwner() {
val field = ReflectionUtil.getDeclaredField(KeyboardFocusManager::class.java, "newFocusOwner")
if (field != null) {

View File

@@ -67,7 +67,6 @@
<orderEntry type="module" module-name="intellij.properties.psi.impl" />
<orderEntry type="module" module-name="intellij.platform.ide.util.io" />
<orderEntry type="module" module-name="intellij.platform.ide.util.netty" />
<orderEntry type="library" name="CGLIB" level="project" />
<orderEntry type="module" module-name="intellij.platform.boot" />
<orderEntry type="module" module-name="intellij.platform.util.text.matching" />
<orderEntry type="module" module-name="intellij.java.impl.refactorings" />

View File

@@ -18,7 +18,6 @@
<orderEntry type="module" module-name="intellij.properties" />
<orderEntry type="module" module-name="intellij.platform.core.ui" />
<orderEntry type="module" module-name="intellij.properties.psi.impl" />
<orderEntry type="library" name="CGLIB" level="project" />
<orderEntry type="module" module-name="intellij.devkit.themes" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.ide.util.io" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.util.ui" scope="TEST" />

View File

@@ -8,7 +8,6 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="intellij.xml.dom" exported="" />
<orderEntry type="library" name="CGLIB" level="project" />
<orderEntry type="module" module-name="intellij.xml.impl" />
<orderEntry type="module" module-name="intellij.platform.util" />
<orderEntry type="module" module-name="intellij.platform.ide" />
@@ -19,6 +18,7 @@
<orderEntry type="module" module-name="intellij.platform.resources" />
<orderEntry type="library" name="fastutil-min" level="project" />
<orderEntry type="module" module-name="intellij.platform.core.ui" />
<orderEntry type="module" module-name="intellij.libraries.cglib" />
</component>
<component name="copyright">
<Base>

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.util.xml.impl;
import com.intellij.openapi.diagnostic.Logger;
@@ -45,7 +45,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public abstract class DomInvocationHandler extends UserDataHolderBase implements InvocationHandler, DomElement {
public abstract class DomInvocationHandler extends UserDataHolderBase implements DomElement {
private static final Logger LOG = Logger.getInstance(DomInvocationHandler.class);
public static final Method ACCEPT_METHOD = ReflectionUtil.getMethod(DomElement.class, "accept", DomElementVisitor.class);
public static final Method ACCEPT_CHILDREN_METHOD = ReflectionUtil.getMethod(DomElement.class, "acceptChildren", DomElementVisitor.class);
@@ -501,7 +501,7 @@ public abstract class DomInvocationHandler extends UserDataHolderBase implements
//noinspection unchecked
implementation = (Class<? extends DomElement>)rawType;
}
myProxy = proxy = AdvancedProxy.createProxy(this, implementation, isInterface ? new Class[]{rawType} : ArrayUtil.EMPTY_CLASS_ARRAY);
myProxy = proxy = AdvancedProxy.createProxy(invocationHandler, implementation, isInterface ? new Class[]{rawType} : ArrayUtil.EMPTY_CLASS_ARRAY);
}
return proxy;
}
@@ -627,15 +627,7 @@ public abstract class DomInvocationHandler extends UserDataHolderBase implements
return new AttributeChildInvocationHandler(evaluatedXmlName, description, myManager, new VirtualDomParentStrategy(this), null);
}
@Override
public final @Nullable Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
try {
return findInvocation(method).invoke(this, args);
}
catch (InvocationTargetException ex) {
throw ex.getTargetException();
}
}
private final InvocationHandler invocationHandler = new MyInvocationHandler();
private @NotNull Invocation findInvocation(Method method) {
Invocation invocation = myAccessorInvocations.get(method);
@@ -862,5 +854,21 @@ public abstract class DomInvocationHandler extends UserDataHolderBase implements
public int hashCode() {
return myChildDescription.hashCode();
}
final class MyInvocationHandler implements InvocationHandler {
DomInvocationHandler getDomInvocationHandler() {
return DomInvocationHandler.this;
}
@Override
public @Nullable Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
try {
return findInvocation(method).invoke(DomInvocationHandler.this, args);
}
catch (InvocationTargetException ex) {
throw ex.getTargetException();
}
}
}
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.util.xml.impl;
import com.intellij.ide.highlighter.DomSupportEnabled;
@@ -226,19 +226,25 @@ public final class DomManagerImpl extends DomManager implements Disposable {
if (proxy instanceof DomFileElement) {
return null;
}
if (proxy instanceof DomInvocationHandler) {
return (DomInvocationHandler)proxy;
if (proxy instanceof DomInvocationHandler h) {
return h;
}
final InvocationHandler handler = AdvancedProxy.getInvocationHandler(proxy);
InvocationHandler handler = AdvancedProxy.getInvocationHandler(proxy);
if (handler instanceof StableInvocationHandler) {
//noinspection unchecked
final DomElement element = ((StableInvocationHandler<DomElement>)handler).getWrappedElement();
DomElement element = ((StableInvocationHandler<DomElement>)handler).getWrappedElement();
return element == null ? null : getDomInvocationHandler(element);
}
if (handler instanceof DomInvocationHandler) {
else if (handler instanceof DomInvocationHandler) {
return (DomInvocationHandler)handler;
}
return null;
else if (handler instanceof DomInvocationHandler.MyInvocationHandler h) {
return h.getDomInvocationHandler();
}
else {
return null;
}
}
public static @NotNull DomInvocationHandler getNotNullHandler(DomElement proxy) {
@@ -273,10 +279,6 @@ public final class DomManagerImpl extends DomManager implements Disposable {
return fileElement;
}
public Set<DomFileDescription<?>> getFileDescriptions(String rootTagName) {
return myApplicationComponent.getFileDescriptions(rootTagName);
}
public Set<DomFileDescription<?>> getAcceptingOtherRootTagNameDescriptions() {
return myApplicationComponent.getAcceptingOtherRootTagNameDescriptions();
}

View File

@@ -8,13 +8,13 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="intellij.xml.dom.impl" />
<orderEntry type="library" name="CGLIB" level="project" />
<orderEntry type="module" module-name="intellij.xml.impl" />
<orderEntry type="module" module-name="intellij.java.testFramework" />
<orderEntry type="module" module-name="intellij.java.psi.impl" />
<orderEntry type="module" module-name="intellij.java.impl" scope="TEST" />
<orderEntry type="library" scope="TEST" name="assertJ" level="project" />
<orderEntry type="module" module-name="intellij.tools.ide.metrics.benchmark" scope="TEST" />
<orderEntry type="module" module-name="intellij.libraries.cglib" scope="TEST" />
</component>
<component name="copyright">
<Base>