dev-java/javapoet: new package, add 1.13.0

Compile dependency of dev-java/auto-value

Signed-off-by: Volkmar W. Pogatzki <gentoo@pogatzki.net>
Part-of: https://github.com/gentoo/gentoo/pull/43470
Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Volkmar W. Pogatzki
2022-04-29 16:59:51 +02:00
committed by Sam James
parent b4ba699fd9
commit 5131eabc92
5 changed files with 215 additions and 0 deletions

View File

@@ -0,0 +1 @@
DIST javapoet-1.13.0.tar.gz 89919 BLAKE2B 5e4cf550ee122a2ddefcd089ffa448a10ef700851d8496d8c130283094bfbeb5997dd373fcd24c5b3739654889d2ebbe3bd9909e7ae3e0c790c3fc2c11de2745 SHA512 3c6118dd57529f6c56e0361f2b07bbc754d9140134cd324109ce6ba4b82e434551ef4409bbba0c7176c2ea10e94e03df014fd8e922162e370b4042999dae270a

View File

@@ -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())

View File

@@ -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)

View File

@@ -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
}

View File

@@ -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>java@gentoo.org</email>
</maintainer>
<upstream>
<remote-id type="github">square/javapoet</remote-id>
</upstream>
</pkgmetadata>