commit:     5131eabc9255be11ee1dc4e18e1ae2093799ccd3
Author:     Volkmar W. Pogatzki <gentoo <AT> pogatzki <DOT> net>
AuthorDate: Fri Apr 29 14:59:51 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Oct  3 05:06:14 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5131eabc

dev-java/javapoet: new package, add 1.13.0

Compile dependency of dev-java/auto-value

Signed-off-by: Volkmar W. Pogatzki <gentoo <AT> pogatzki.net>
Part-of: https://github.com/gentoo/gentoo/pull/43470
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-java/javapoet/Manifest                         |  1 +
 .../files/javapoet-1.13.0-ClassNameTest.patch      | 83 ++++++++++++++++++++++
 .../files/javapoet-1.13.0-skipFailingTests.patch   | 46 ++++++++++++
 dev-java/javapoet/javapoet-1.13.0.ebuild           | 75 +++++++++++++++++++
 dev-java/javapoet/metadata.xml                     | 10 +++
 5 files changed, 215 insertions(+)

diff --git a/dev-java/javapoet/Manifest b/dev-java/javapoet/Manifest
new file mode 100644
index 000000000000..a4d2145a040e
--- /dev/null
+++ b/dev-java/javapoet/Manifest
@@ -0,0 +1 @@
+DIST javapoet-1.13.0.tar.gz 89919 BLAKE2B 
5e4cf550ee122a2ddefcd089ffa448a10ef700851d8496d8c130283094bfbeb5997dd373fcd24c5b3739654889d2ebbe3bd9909e7ae3e0c790c3fc2c11de2745
 SHA512 
3c6118dd57529f6c56e0361f2b07bbc754d9140134cd324109ce6ba4b82e434551ef4409bbba0c7176c2ea10e94e03df014fd8e922162e370b4042999dae270a

diff --git a/dev-java/javapoet/files/javapoet-1.13.0-ClassNameTest.patch 
b/dev-java/javapoet/files/javapoet-1.13.0-ClassNameTest.patch
new file mode 100644
index 000000000000..38e028d15aa0
--- /dev/null
+++ b/dev-java/javapoet/files/javapoet-1.13.0-ClassNameTest.patch
@@ -0,0 +1,83 @@
+There was 1 failure:
+1) 
classNameFromTypeElementDoesntUseGetKind(com.squareup.javapoet.ClassNameTest)
+org.mockito.exceptions.base.MockitoException: 
+Mockito cannot mock this class: class 
com.sun.tools.javac.code.Symbol$ClassSymbol.
+
+Mockito can only mock non-private & non-final classes.
+If you're not sure why you're getting this error, please report to the mailing 
list.
+
+
+Java               : 25
+JVM vendor name    : Gentoo
+JVM vendor version : 25+17
+JVM name           : OpenJDK 64-Bit Server VM
+JVM version        : 25+17
+JVM info           : mixed mode, sharing
+OS name            : Linux
+OS version         : 6.12.21-gentoo
+
+
+Underlying exception : org.mockito.exceptions.base.MockitoException: 
+Could not force module adjustment of the module of class 
com.sun.tools.javac.code.Symbol$ClassSymbol
+
+This is required to adjust the module graph to enable mock creation
+       at 
com.squareup.javapoet.ClassNameTest.preventGetKind(ClassNameTest.java:134)
+       at 
com.squareup.javapoet.ClassNameTest.classNameFromTypeElementDoesntUseGetKind(ClassNameTest.java:122)
+       ... 45 trimmed
+Caused by: org.mockito.exceptions.base.MockitoException: 
+Could not force module adjustment of the module of class 
com.sun.tools.javac.code.Symbol$ClassSymbol
+
+This is required to adjust the module graph to enable mock creation
+       at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:168)
+       at 
net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:399)
+       at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:190)
+       at 
net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:410)
+       ... 48 more
+Caused by: java.lang.IllegalArgumentException: 
com.sun.tools.javac.code.Symbol$ClassSymbol$MockitoModuleProbe$58544662 must be 
defined in the same package as org.mockito.codegen.InjectionBase
+       at 
net.bytebuddy.dynamic.loading.ClassInjector$UsingLookup.injectRaw(ClassInjector.java:1683)
+       at 
net.bytebuddy.dynamic.loading.ClassInjector$AbstractBase.injectRaw(ClassInjector.java:167)
+       at 
net.bytebuddy.dynamic.loading.ClassInjector$AbstractBase.inject(ClassInjector.java:155)
+       at 
net.bytebuddy.dynamic.loading.ClassLoadingStrategy$UsingLookup.load(ClassLoadingStrategy.java:519)
+       at 
net.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:101)
+       at 
net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:6432)
+       at 
org.mockito.internal.creation.bytebuddy.ModuleHandler$ModuleSystemFound.adjustModuleGraph(ModuleHandler.java:198)
+       at 
org.mockito.internal.creation.bytebuddy.SubclassBytecodeGenerator.mockClass(SubclassBytecodeGenerator.java:106)
+       at 
org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:37)
+       at 
org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:34)
+       at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:168)
+       at 
net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:399)
+       at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:190)
+       at 
net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:410)
+       at 
org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.mockClass(TypeCachingBytecodeGenerator.java:32)
+       at 
org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMockType(SubclassByteBuddyMockMaker.java:71)
+       at 
org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMock(SubclassByteBuddyMockMaker.java:42)
+       at 
org.mockito.internal.creation.bytebuddy.ByteBuddyMockMaker.createMock(ByteBuddyMockMaker.java:25)
+       at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:35)
+       at org.mockito.internal.MockitoCore.mock(MockitoCore.java:62)
+       at org.mockito.Mockito.spy(Mockito.java:1992)
+       ... 48 more
+
+FAILURES!!!
+Tests run: 383,  Failures: 1
+
+With Java versions 21 and lower the tests pass.
+
+--- a/src/test/java/com/squareup/javapoet/ClassNameTest.java
++++ b/src/test/java/com/squareup/javapoet/ClassNameTest.java
+@@ -21,6 +21,7 @@ import javax.lang.model.element.TypeElement;
+ import javax.lang.model.util.Elements;
+ import org.junit.Rule;
+ import org.junit.Test;
++import org.junit.Ignore;
+ import org.junit.runner.RunWith;
+ import org.junit.runners.JUnit4;
+ import org.mockito.Mockito;
+@@ -116,7 +117,7 @@ public final class ClassNameTest {
+    * Buck builds with "source-based ABI generation" and those builds don't 
support
+    * {@link TypeElement#getKind()}. Test to confirm that we don't use that 
API.
+    */
+-  @Test public void classNameFromTypeElementDoesntUseGetKind() {
++  @Test @Ignore public void classNameFromTypeElementDoesntUseGetKind() {
+     Elements elements = compilationRule.getElements();
+     TypeElement object = 
elements.getTypeElement(Object.class.getCanonicalName());
+     assertThat(ClassName.get(preventGetKind(object)).toString())

diff --git a/dev-java/javapoet/files/javapoet-1.13.0-skipFailingTests.patch 
b/dev-java/javapoet/files/javapoet-1.13.0-skipFailingTests.patch
new file mode 100644
index 000000000000..79d7665c4c91
--- /dev/null
+++ b/dev-java/javapoet/files/javapoet-1.13.0-skipFailingTests.patch
@@ -0,0 +1,46 @@
+
+
+There was 1 failure:
+1) overrideGenerics(com.squareup.javapoet.MethodSpecTest)
+expected:
+    @java.lang.Override
+    <T, R, V extends java.lang.Throwable> T run(R param) throws V {
+      return null;
+    }
+    
+but was:
+    @java.lang.Override
+    <T, R, V extends java.lang.Throwable> T run(R arg0) throws V {
+      return null;
+    }
+    
+       at 
com.squareup.javapoet.MethodSpecTest.overrideGenerics(MethodSpecTest.java:167)
+
+FAILURES!!!
+Tests run: 384,  Failures: 1
+
+Built and tests run with Java 21.
+
+Testing with java 25 would need asm-jdk-bridge built with target 25:
+Caused by: java.lang.IllegalStateException:
+Could not invoke proxy: Type not available on current VM: 
codes.rafael.asmjdkbridge.JdkClassWriter
+
+--- a/src/test/java/com/squareup/javapoet/MethodSpecTest.java
++++ b/src/test/java/com/squareup/javapoet/MethodSpecTest.java
+@@ -39,6 +39,7 @@ import javax.tools.JavaFileObject;
+ import org.junit.Before;
+ import org.junit.Rule;
+ import org.junit.Test;
++import org.junit.Ignore;
+ 
+ import static com.google.common.collect.Iterables.getOnlyElement;
+ import static com.google.common.truth.Truth.assertThat;
+@@ -158,7 +159,7 @@ public final class MethodSpecTest {
+         + "}\n");
+   }
+ 
+-  @Test public void overrideGenerics() {
++  @Test @Ignore public void overrideGenerics() {
+     TypeElement classElement = getElement(Generics.class);
+     ExecutableElement methodElement = 
getOnlyElement(methodsIn(classElement.getEnclosedElements()));
+     MethodSpec method = MethodSpec.overriding(methodElement)

diff --git a/dev-java/javapoet/javapoet-1.13.0.ebuild 
b/dev-java/javapoet/javapoet-1.13.0.ebuild
new file mode 100644
index 000000000000..eae3a16fa9e3
--- /dev/null
+++ b/dev-java/javapoet/javapoet-1.13.0.ebuild
@@ -0,0 +1,75 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+JAVA_PKG_IUSE="doc source test"
+JAVA_TESTING_FRAMEWORKS="junit-4"
+
+inherit java-pkg-2 java-pkg-simple
+
+DESCRIPTION="Use beautiful Java code to generate beautiful Java code."
+HOMEPAGE="https://github.com/square/javapoet/";
+SRC_URI="https://github.com/square/${PN}/archive/${P}.tar.gz";
+S="${WORKDIR}/${PN}-${P}"
+
+LICENSE="Apache-2.0"
+SLOT="0"
+KEYWORDS="~amd64"
+
+DEPEND="
+       >=virtual/jdk-1.8:*
+       test? (
+               dev-java/eclipse-ecj:4.20
+               dev-java/compile-testing:0
+               dev-java/jimfs:0
+               dev-java/junit:4
+               dev-java/mockito:2
+               dev-java/truth:0
+       )
+"
+
+RDEPEND=">=virtual/jre-1.8:*"
+
+PATCHES=(
+       "${FILESDIR}/javapoet-1.13.0-skipFailingTests.patch"
+       "${FILESDIR}/javapoet-1.13.0-ClassNameTest.patch"       # works with 
Java <= 21
+)
+
+JAVA_AUTOMATIC_MODULE_NAME="com.squareup.javapoet"
+JAVA_SRC_DIR="src/main/java"
+
+JAVA_TEST_EXCLUDES=(
+       com.squareup.javapoet.TestUtil  # no runnable methods
+       com.squareup.javapoet.TestFiler # no runnable methods
+)
+
+JAVA_TEST_GENTOO_CLASSPATH="
+       compile-testing
+       eclipse-ecj-4.20
+       jimfs
+       junit-4
+       mockito-2
+"
+
+JAVA_TEST_SRC_DIR="src/test/java"
+
+src_prepare() {
+       default #780585
+       java-pkg-2_src_prepare
+}
+
+src_test() {
+       # Having 'truth' in JAVA_TEST_GENTOO_CLASSPATH would cause one test 
failure
+       # on 'compileJavaFile(com.squareup.javapoet.FileReadingTest)'.
+       # The eclass builds that classpath '--with-dependencies' which would 
add the
+       # annotation processor so that annotation processing gets enabled.
+       JAVA_GENTOO_CLASSPATH_EXTRA+=":$(java-pkg_getjars --build-only truth)"
+
+       local vm_version="$(java-config -g PROVIDES_VERSION)"
+       if ver_test "${vm_version}" -ge 17; then
+               JAVA_TEST_EXTRA_ARGS+=( 
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED )
+               JAVA_TEST_EXTRA_ARGS+=( 
--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED )
+       fi
+       java-pkg-simple_src_test
+}

diff --git a/dev-java/javapoet/metadata.xml b/dev-java/javapoet/metadata.xml
new file mode 100644
index 000000000000..981e00eb9352
--- /dev/null
+++ b/dev-java/javapoet/metadata.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd";>
+<pkgmetadata>
+       <maintainer type="project">
+               <email>[email protected]</email>
+       </maintainer>
+       <upstream>
+               <remote-id type="github">square/javapoet</remote-id>
+       </upstream>
+</pkgmetadata>

Reply via email to