1- From 6a2d82a72828ffc1a7e686b62a57ef86a3f60c58 Mon Sep 17 00:00:00 2001
1+ From c1e8f17846cb69ef2a3768dee7cfadb40858d279 Mon Sep 17 00:00:00 2001
22From: Akash Yadav <akashyadav@appdevforall.org>
33Date: Thu, 26 Mar 2026 14:35:40 +0530
44Subject: [PATCH 6/9] feat: add android-shims module
@@ -12,25 +12,32 @@ Signed-off-by: Akash Yadav <akashyadav@appdevforall.org>
1212---
1313 build.gradle.kts | 1 +
1414 gradle/verification-metadata.xml | 5 +
15+ .../build.gradle.kts | 5 +-
1516 .../android-shims/build.gradle.kts | 80 ++++++++++
1617 .../benmanes/caffeine/base/UnsafeAccess.java | 52 +++++++
1718 .../benmanes/caffeine/cache/UnsafeAccess.java | 85 ++++++++++
1819 .../openapi/util/LowMemoryWatcherManager.java | 86 +++++++++++
1920 .../util/DebugAttachDetectorArgs.java | 57 +++++++
2021 .../com/intellij/util/containers/Unsafe.java | 138 +++++++++++++++++
22+ .../java/com/android/java/awt/Component.java | 6 +
23+ .../java/com/android/java/awt/Graphics.java | 101 ++++++++++++
24+ .../java/com/android/javax/swing/Icon.java | 65 ++++++++
2125 .../android/javax/swing/SwingUtilities.java | 145 ++++++++++++++++++
2226 .../openapi/util/LowMemoryWatcherAccess.java | 8 +
2327 .../src/main/java/gnu/trove/Equality.java | 53 +++++++
2428 .../gnu/trove/TObjectHashingStrategy.java | 64 ++++++++
2529 .../internal/intellij/IntellijCoroutines.kt | 29 ++++
2630 settings.gradle | 3 +-
27- 14 files changed, 805 insertions(+), 1 deletion (-)
31+ 18 files changed, 981 insertions(+), 2 deletions (-)
2832 create mode 100644 prepare/ide-plugin-dependencies/android-shims/build.gradle.kts
2933 create mode 100644 prepare/ide-plugin-dependencies/android-shims/src/main/java/com/android/com/github/benmanes/caffeine/base/UnsafeAccess.java
3034 create mode 100644 prepare/ide-plugin-dependencies/android-shims/src/main/java/com/android/com/github/benmanes/caffeine/cache/UnsafeAccess.java
3135 create mode 100644 prepare/ide-plugin-dependencies/android-shims/src/main/java/com/android/com/intellij/openapi/util/LowMemoryWatcherManager.java
3236 create mode 100644 prepare/ide-plugin-dependencies/android-shims/src/main/java/com/android/com/intellij/util/DebugAttachDetectorArgs.java
3337 create mode 100644 prepare/ide-plugin-dependencies/android-shims/src/main/java/com/android/com/intellij/util/containers/Unsafe.java
38+ create mode 100644 prepare/ide-plugin-dependencies/android-shims/src/main/java/com/android/java/awt/Component.java
39+ create mode 100644 prepare/ide-plugin-dependencies/android-shims/src/main/java/com/android/java/awt/Graphics.java
40+ create mode 100644 prepare/ide-plugin-dependencies/android-shims/src/main/java/com/android/javax/swing/Icon.java
3441 create mode 100644 prepare/ide-plugin-dependencies/android-shims/src/main/java/com/android/javax/swing/SwingUtilities.java
3542 create mode 100644 prepare/ide-plugin-dependencies/android-shims/src/main/java/com/intellij/openapi/util/LowMemoryWatcherAccess.java
3643 create mode 100644 prepare/ide-plugin-dependencies/android-shims/src/main/java/gnu/trove/Equality.java
@@ -65,6 +72,22 @@ index 49b8f09b6ab5..3dcb79b69065 100644
6572 <component group="org.lz4" name="lz4-java" version="1.7.1">
6673 <artifact name="lz4-java-1.7.1.jar">
6774 <md5 value="d56d86823662a663a4d614dd5e117eff" origin="Generated by Gradle"/>
75+ diff --git a/prepare/ide-plugin-dependencies/analysis-api-standalone-embeddable-for-ide/build.gradle.kts b/prepare/ide-plugin-dependencies/analysis-api-standalone-embeddable-for-ide/build.gradle.kts
76+ index a1dffb3abc9f..08f359c3060b 100644
77+ --- a/prepare/ide-plugin-dependencies/analysis-api-standalone-embeddable-for-ide/build.gradle.kts
78+ +++ b/prepare/ide-plugin-dependencies/analysis-api-standalone-embeddable-for-ide/build.gradle.kts
79+ @@ -59,7 +59,10 @@ val classesToReplaceInComIntellij = mapOf(
80+ val classesToReplace = mapOf(
81+ "com.github.benmanes.caffeine.base.UnsafeAccess" to "com.android.",
82+ "com.github.benmanes.caffeine.cache.UnsafeAccess" to "com.android.",
83+ - "javax.swing.SwingUtilities" to "com.android."
84+ + "java.awt.Component" to "com.android.",
85+ + "java.awt.Graphics" to "com.android.",
86+ + "javax.swing.Icon" to "com.android.",
87+ + "javax.swing.SwingUtilities" to "com.android.",
88+ )
89+
90+ tasks.register<ShadowJar>("embeddable") {
6891diff --git a/prepare/ide-plugin-dependencies/android-shims/build.gradle.kts b/prepare/ide-plugin-dependencies/android-shims/build.gradle.kts
6992new file mode 100644
7093index 000000000000..8dbcf1627d3f
@@ -600,6 +623,199 @@ index 000000000000..7fd8ec2e0909
600623+ return (sun.misc.Unsafe) unsafe;
601624+ }
602625+ }
626+ diff --git a/prepare/ide-plugin-dependencies/android-shims/src/main/java/com/android/java/awt/Component.java b/prepare/ide-plugin-dependencies/android-shims/src/main/java/com/android/java/awt/Component.java
627+ new file mode 100644
628+ index 000000000000..f39d16465dc8
629+ --- /dev/null
630+ +++ b/prepare/ide-plugin-dependencies/android-shims/src/main/java/com/android/java/awt/Component.java
631+ @@ -0,0 +1,6 @@
632+ + package com.android.java.awt;
633+ +
634+ + public abstract class Component {
635+ +
636+ + // COTG-changed: stub class
637+ + }
638+ \ No newline at end of file
639+ diff --git a/prepare/ide-plugin-dependencies/android-shims/src/main/java/com/android/java/awt/Graphics.java b/prepare/ide-plugin-dependencies/android-shims/src/main/java/com/android/java/awt/Graphics.java
640+ new file mode 100644
641+ index 000000000000..70dd08df8208
642+ --- /dev/null
643+ +++ b/prepare/ide-plugin-dependencies/android-shims/src/main/java/com/android/java/awt/Graphics.java
644+ @@ -0,0 +1,101 @@
645+ + /*
646+ + * Copyright (c) 1995, 2022, Oracle and/or its affiliates. All rights reserved.
647+ + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
648+ + *
649+ + * This code is free software; you can redistribute it and/or modify it
650+ + * under the terms of the GNU General Public License version 2 only, as
651+ + * published by the Free Software Foundation. Oracle designates this
652+ + * particular file as subject to the "Classpath" exception as provided
653+ + * by Oracle in the LICENSE file that accompanied this code.
654+ + *
655+ + * This code is distributed in the hope that it will be useful, but WITHOUT
656+ + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
657+ + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
658+ + * version 2 for more details (a copy is included in the LICENSE file that
659+ + * accompanied this code).
660+ + *
661+ + * You should have received a copy of the GNU General Public License version
662+ + * 2 along with this work; if not, write to the Free Software Foundation,
663+ + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
664+ + *
665+ + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
666+ + * or visit www.oracle.com if you need additional information or have any
667+ + * questions.
668+ + */
669+ + package com.android.java.awt;
670+ +
671+ + /**
672+ + * The {@code Graphics} class is the abstract base class for
673+ + * all graphics contexts that allow an application to draw onto
674+ + * components that are realized on various devices, as well as
675+ + * onto off-screen images.
676+ + * <p>
677+ + * A {@code Graphics} object encapsulates state information needed
678+ + * for the basic rendering operations that Java supports. This
679+ + * state information includes the following properties:
680+ + *
681+ + * <ul>
682+ + * <li>The {@code Component} object on which to draw.
683+ + * <li>A translation origin for rendering and clipping coordinates.
684+ + * <li>The current clip.
685+ + * <li>The current color.
686+ + * <li>The current font.
687+ + * <li>The current logical pixel operation function (XOR or Paint).
688+ + * <li>The current XOR alternation color
689+ + * (see {@link Graphics#setXORMode}).
690+ + * </ul>
691+ + * <p>
692+ + * Coordinates are infinitely thin and lie between the pixels of the
693+ + * output device.
694+ + * Operations that draw the outline of a figure operate by traversing
695+ + * an infinitely thin path between pixels with a pixel-sized pen that hangs
696+ + * down and to the right of the anchor point on the path.
697+ + * Operations that fill a figure operate by filling the interior
698+ + * of that infinitely thin path.
699+ + * Operations that render horizontal text render the ascending
700+ + * portion of character glyphs entirely above the baseline coordinate.
701+ + * <p>
702+ + * The graphics pen hangs down and to the right from the path it traverses.
703+ + * This has the following implications:
704+ + * <ul>
705+ + * <li>If you draw a figure that covers a given rectangle, that
706+ + * figure occupies one extra row of pixels on the right and bottom edges
707+ + * as compared to filling a figure that is bounded by that same rectangle.
708+ + * <li>If you draw a horizontal line along the same <i>y</i> coordinate as
709+ + * the baseline of a line of text, that line is drawn entirely below
710+ + * the text, except for any descenders.
711+ + * </ul><p>
712+ + * All coordinates that appear as arguments to the methods of this
713+ + * {@code Graphics} object are considered relative to the
714+ + * translation origin of this {@code Graphics} object prior to
715+ + * the invocation of the method.
716+ + * <p>
717+ + * All rendering operations modify only pixels which lie within the
718+ + * area bounded by the current clip, which is specified by a {@link Shape}
719+ + * in user space and is controlled by the program using the
720+ + * {@code Graphics} object. This <i>user clip</i>
721+ + * is transformed into device space and combined with the
722+ + * <i>device clip</i>, which is defined by the visibility of windows and
723+ + * device extents. The combination of the user clip and device clip
724+ + * defines the <i>composite clip</i>, which determines the final clipping
725+ + * region. The user clip cannot be modified by the rendering
726+ + * system to reflect the resulting composite clip. The user clip can only
727+ + * be changed through the {@code setClip} or {@code clipRect}
728+ + * methods.
729+ + * All drawing or writing is done in the current color,
730+ + * using the current paint mode, and in the current font.
731+ + *
732+ + * @author Sami Shaio
733+ + * @author Arthur van Hoff
734+ + * @see java.awt.Component
735+ + * @see java.awt.Graphics#clipRect(int, int, int, int)
736+ + * @see java.awt.Graphics#setColor(java.awt.Color)
737+ + * @see java.awt.Graphics#setPaintMode()
738+ + * @see java.awt.Graphics#setXORMode(java.awt.Color)
739+ + * @see java.awt.Graphics#setFont(java.awt.Font)
740+ + * @since 1.0
741+ + */
742+ + public abstract class Graphics {
743+ +
744+ + // COTG-changed: stub class
745+ + }
746+ \ No newline at end of file
747+ diff --git a/prepare/ide-plugin-dependencies/android-shims/src/main/java/com/android/javax/swing/Icon.java b/prepare/ide-plugin-dependencies/android-shims/src/main/java/com/android/javax/swing/Icon.java
748+ new file mode 100644
749+ index 000000000000..928d914a0652
750+ --- /dev/null
751+ +++ b/prepare/ide-plugin-dependencies/android-shims/src/main/java/com/android/javax/swing/Icon.java
752+ @@ -0,0 +1,65 @@
753+ + /*
754+ + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
755+ + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
756+ + *
757+ + * This code is free software; you can redistribute it and/or modify it
758+ + * under the terms of the GNU General Public License version 2 only, as
759+ + * published by the Free Software Foundation. Oracle designates this
760+ + * particular file as subject to the "Classpath" exception as provided
761+ + * by Oracle in the LICENSE file that accompanied this code.
762+ + *
763+ + * This code is distributed in the hope that it will be useful, but WITHOUT
764+ + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
765+ + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
766+ + * version 2 for more details (a copy is included in the LICENSE file that
767+ + * accompanied this code).
768+ + *
769+ + * You should have received a copy of the GNU General Public License version
770+ + * 2 along with this work; if not, write to the Free Software Foundation,
771+ + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
772+ + *
773+ + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
774+ + * or visit www.oracle.com if you need additional information or have any
775+ + * questions.
776+ + */
777+ + package com.android.javax.swing;
778+ +
779+ + import com.android.java.awt.Graphics;
780+ + import com.android.java.awt.Component;
781+ +
782+ +
783+ + /**
784+ + * A small fixed size picture, typically used to decorate components.
785+ + *
786+ + * @see ImageIcon
787+ + * @since 1.2
788+ + */
789+ +
790+ + public interface Icon
791+ + {
792+ + /**
793+ + * Draw the icon at the specified location. Icon implementations
794+ + * may use the Component argument to get properties useful for
795+ + * painting, e.g. the foreground or background color.
796+ + *
797+ + * @param c a {@code Component} to get properties useful for painting
798+ + * @param g the graphics context
799+ + * @param x the X coordinate of the icon's top-left corner
800+ + * @param y the Y coordinate of the icon's top-left corner
801+ + */
802+ + void paintIcon(Component c, Graphics g, int x, int y);
803+ +
804+ + /**
805+ + * Returns the icon's width.
806+ + *
807+ + * @return an int specifying the fixed width of the icon.
808+ + */
809+ + int getIconWidth();
810+ +
811+ + /**
812+ + * Returns the icon's height.
813+ + *
814+ + * @return an int specifying the fixed height of the icon.
815+ + */
816+ + int getIconHeight();
817+ + }
818+ \ No newline at end of file
603819diff --git a/prepare/ide-plugin-dependencies/android-shims/src/main/java/com/android/javax/swing/SwingUtilities.java b/prepare/ide-plugin-dependencies/android-shims/src/main/java/com/android/javax/swing/SwingUtilities.java
604820new file mode 100644
605821index 000000000000..da78643534cc
0 commit comments