Skip to content

Commit

Permalink
bump to kotlin 1.5.20
Browse files Browse the repository at this point in the history
Ignore synthetic methods in RESTEasy Reactive and Reactive Messaging

This is done in order to account for the fact that in Kotlin 1.5
the compiler copies the annotations from the suspend method to the
corresponding synthetic method
  • Loading branch information
evanchooly committed Jul 1, 2021
1 parent aa303a8 commit 64bc781
Show file tree
Hide file tree
Showing 18 changed files with 76 additions and 34 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/jdk-early-access-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ jobs:
# -fae to try to gather as many failures as possible
# (but not maven.test.failure.ignore because test report generation is buggy)
# Gradle bits are excluded due to https://github.com/gradle/gradle/issues/13481
# descriptor-tests (integration-tests/maven) are disabled due to https://github.com/quarkusio/quarkus/issues/16862 (and/or 16806)
run: |
./mvnw $JVM_TEST_MAVEN_OPTS -Dtcks install -fae -pl '!devtools/gradle' -pl '!integration-tests/gradle' -Dno-descriptor-tests
./mvnw $JVM_TEST_MAVEN_OPTS -Dtcks install -fae -pl '!devtools/gradle' -pl '!integration-tests/gradle'
# Test reports disabled due to: https://github.com/ScaCap/action-surefire-report/issues/39
#- name: Publish Test Report
# if: always()
Expand Down
1 change: 0 additions & 1 deletion .mvn/jvm.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
-Dmaven.wagon.httpconnectionManager.ttlSeconds=120
-Dmaven.wagon.http.retryHandler.requestSentEnabled=true
-Dmaven.wagon.http.retryHandler.count=10
-Dkotlin.environment.keepalive=true
-Xmx5g
4 changes: 2 additions & 2 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@
<awssdk.version>2.16.92</awssdk.version>
<aws-alexa-sdk.version>2.39.0</aws-alexa-sdk.version>
<azure-functions-java-library.version>1.4.2</azure-functions-java-library.version>
<kotlin.version>1.4.32</kotlin.version>
<kotlin.coroutine.version>1.4.3</kotlin.coroutine.version>
<kotlin.version>1.5.20</kotlin.version>
<kotlin.coroutine.version>1.5.0</kotlin.coroutine.version>
<dekorate.version>2.2.2</dekorate.version>
<maven-artifact-transfer.version>0.10.0</maven-artifact-transfer.version>
<maven-invoker.version>3.0.1</maven-invoker.version>
Expand Down
2 changes: 1 addition & 1 deletion build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<!-- These properties are needed in order for them to be resolvable by the generated projects -->
<!-- Quarkus uses jboss-parent and it comes with 3.8.1-jboss-1, we don't want that in the templates -->
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<kotlin.version>1.5.20</kotlin.version>
<dokka.version>1.4.32</dokka.version>
<kotlin.version>1.4.32</kotlin.version>
<scala.version>2.12.13</scala.version>
<scala-maven-plugin.version>4.4.0</scala-maven-plugin.version>
<!-- not pretty but this is used in the codestarts and we don't want to break compatibility -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public String internalName() {
return type.getInternalName();
}

public boolean isPrimitive() {
return type().getSort() <= Type.DOUBLE;
}

private Type toAsm(PrimitiveType primitive) {
switch (primitive.name().toString()) {
case "byte":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,9 @@ private String desc(String name) {
}

private void descriptors(MethodInfo method, StringJoiner joiner) {
ByteCodeType id = typeArguments.get("Id");
for (Type parameter : method.parameters()) {
if (parameter.kind() == Type.Kind.TYPE_VARIABLE
|| method.name().endsWith("ById")
&& parameter.name().equals(typeArguments.get("Id").dotName())) {
if (!id.isPrimitive() && parameter.name().equals(id.dotName())) {
joiner.add(OBJECT.descriptor());
} else {
joiner.add(mapType(parameter));
Expand Down Expand Up @@ -360,13 +359,7 @@ private void emitLocalVariablesTable(MethodVisitor mv, MethodInfo method) {
}
}

private void generateBridge(MethodInfo method) {
// get a bounds-erased descriptor
String descriptor = bridgeMethodDescriptor(method, type -> {
ByteCodeType mapped = typeArguments.get(type);
return mapped != null ? mapped.descriptor() : type;
});
// make sure we need a bridge
private void generateBridge(MethodInfo method, String descriptor) {
MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC | Opcodes.ACC_BRIDGE,
method.name(),
descriptor,
Expand Down Expand Up @@ -407,6 +400,31 @@ private void generateBridge(MethodInfo method) {

}

private void generatePrimitiveBridge(MethodInfo method, String descriptor) {
String substring = descriptor.substring(0, descriptor.lastIndexOf(')') + 1);
String descriptor1 = substring + OBJECT.descriptor();
MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC | Opcodes.ACC_BRIDGE,
method.name(),
descriptor1,
null,
null);
AsmUtil.copyParameterNames(mv, method);
mv.visitCode();
// this
mv.visitIntInsn(Opcodes.ALOAD, 0);
mv.visitIntInsn(typeArguments.get("Id").type().getOpcode(ILOAD), 1);
String targetDescriptor = getDescriptor(method, name -> typeArguments.get(name).descriptor());
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL,
classInfo.name().toString().replace('.', '/'),
method.name(),
targetDescriptor, false);
String targetReturnTypeDescriptor = targetDescriptor.substring(targetDescriptor.indexOf(')') + 1);
mv.visitInsn(AsmUtil.getReturnInstruction(targetReturnTypeDescriptor));
mv.visitMaxs(0, 0);
mv.visitEnd();

}

private void invokeOperation(MethodVisitor mv, MethodInfo method) {
String operationDescriptor;

Expand Down Expand Up @@ -538,7 +556,16 @@ public void visitEnd() {
return mapped != null ? mapped.descriptor() : type;
});
if (!definedMethods.containsKey(method.name() + bridgeDescriptor)) {
generateBridge(method);
generateBridge(method, bridgeDescriptor);
}

AnnotationValue targetReturnTypeErased = bridge.value("targetReturnTypeErased");
if (typeArguments.get("Id").isPrimitive() && targetReturnTypeErased != null
&& targetReturnTypeErased.asBoolean()) {
if (method.parameters().size() == 1
&& method.parameters().get(0).asTypeVariable().identifier().equals("Id")) {
generatePrimitiveBridge(method, descriptor);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.jboss.jandex.MethodInfo;
import org.jboss.jandex.Type;
import org.jboss.logging.Logger;
import org.objectweb.asm.Opcodes;

import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
import io.quarkus.arc.deployment.AnnotationsTransformerBuildItem;
Expand Down Expand Up @@ -164,6 +165,9 @@ void collectComponents(BeanDiscoveryFinishedBuildItem beanDiscoveryFinished,
validationErrors.produce(new ValidationErrorBuildItem(
new DeploymentException("Empty @Outgoing annotation on method " + method)));
}
if (isSynthetic(method.flags())) {
continue;
}
// TODO: validate method params and return type?
mediatorMethods.produce(new MediatorBuildItem(bean, method));
LOGGER.debugf("Found mediator business method %s declared on %s", method, bean);
Expand Down Expand Up @@ -236,6 +240,10 @@ void collectComponents(BeanDiscoveryFinishedBuildItem beanDiscoveryFinished,

}

private boolean isSynthetic(int mod) {
return (mod & Opcodes.ACC_SYNTHETIC) != 0;
}

private Optional<AnnotationInstance> getAnnotation(TransformedAnnotationsBuildItem transformedAnnotations,
InjectionPointInfo injectionPoint,
DotName annotationName) {
Expand Down
2 changes: 1 addition & 1 deletion extensions/smallrye-reactive-messaging/kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
<plugin>
<groupId>org.jetbrains.dokka</groupId>
<artifactId>dokka-maven-plugin</artifactId>
<version>1.4.32</version>
<version>${dokka.version}</version>
<executions>
<execution>
<id>javadoc</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
import org.jboss.resteasy.reactive.common.util.ReflectionBeanFactoryCreator;
import org.jboss.resteasy.reactive.common.util.URLUtils;
import org.jboss.resteasy.reactive.spi.BeanFactory;
import org.objectweb.asm.Opcodes;

public abstract class EndpointIndexer<T extends EndpointIndexer<T, PARAM, METHOD>, PARAM extends IndexedParameter<PARAM>, METHOD extends ResourceMethod> {

Expand Down Expand Up @@ -364,19 +365,28 @@ private void validateHttpAnnotations(MethodInfo info) {
}

private boolean hasProperModifiers(MethodInfo info) {
if (isSynthetic(info.flags())) {
log.debug("Method '" + info.name() + " of Resource class '" + info.declaringClass().name()
+ "' is a synthetic method and will therefore be ignored");
return false;
}
if ((info.flags() & Modifier.PUBLIC) == 0) {
log.warn("Method '" + info.name() + " of Resource class '" + info.declaringClass().name()
+ "' it not public and will therefore be ignored");
+ "' is not public and will therefore be ignored");
return false;
}
if ((info.flags() & Modifier.STATIC) != 0) {
log.warn("Method '" + info.name() + " of Resource class '" + info.declaringClass().name()
+ "' it static and will therefore be ignored");
+ "' is static and will therefore be ignored");
return false;
}
return true;
}

private boolean isSynthetic(int mod) {
return (mod & Opcodes.ACC_SYNTHETIC) != 0;
}

private ResourceMethod createResourceMethod(ClassInfo currentClassInfo, ClassInfo actualEndpointInfo,
String[] classProduces, String[] classConsumes, Set<String> classNameBindings, DotName httpMethod,
MethodInfo currentMethodInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public void testRunTogetherCodestartsJava() throws Exception {
}

@Test
@org.junit.jupiter.api.Tag("failsOnJDK16")
public void testRunTogetherCodestartsKotlin() throws Exception {
generateProjectRunTests("maven", "kotlin", getExtensionCodestarts());
}
Expand Down Expand Up @@ -91,7 +90,6 @@ public void testRunAloneCodestartsJava(String codestart) throws Exception {

@ParameterizedTest
@MethodSource("provideRunAloneCodestarts")
@org.junit.jupiter.api.Tag("failsOnJDK16")
public void testRunAloneCodestartsKotlin(String codestart) throws Exception {
generateProjectRunTests("maven", "kotlin", singletonList(codestart));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
id 'java'
id 'io.quarkus'
id 'org.jetbrains.kotlin.jvm' version "1.4.32"
id "org.jetbrains.kotlin.plugin.allopen" version "1.4.32"
id 'org.jetbrains.kotlin.jvm' version "1.5.20"
id "org.jetbrains.kotlin.plugin.allopen" version "1.5.20"
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'org.jetbrains.kotlin.jvm' version "1.4.32"
id "org.jetbrains.kotlin.plugin.allopen" version "1.4.32"
id 'org.jetbrains.kotlin.jvm' version "1.5.20"
id "org.jetbrains.kotlin.plugin.allopen" version "1.5.20"
id 'io.quarkus'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
quarkusPlatformArtifactId=quarkus-bom
quarkusPlatformGroupId=io.quarkus

kotlinVersion=1.4.32
kotlinVersion=1.5.20

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version "1.4.32"
id "org.jetbrains.kotlin.plugin.allopen" version "1.4.32"
id 'org.jetbrains.kotlin.jvm' version "1.5.20"
id "org.jetbrains.kotlin.plugin.allopen" version "1.5.20"
id 'io.quarkus'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
public class KotlinDevModeIT extends RunAndCheckMojoTestBase {

@Test
@Tag("failsOnJDK16")
public void testThatTheApplicationIsReloadedOnKotlinChange() throws MavenInvocationException, IOException {
testDir = initProject("projects/classic-kotlin", "projects/project-classic-run-kotlin-change");
runAndCheck(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.util.concurrent.TimeUnit;

import org.apache.maven.shared.invoker.MavenInvocationException;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import com.google.common.collect.ImmutableMap;
Expand All @@ -19,7 +18,6 @@
public class KotlinRemoteDevModeIT extends RunAndCheckWithAgentMojoTestBase {

@Test
@Tag("failsOnJDK16")
public void testThatTheApplicationIsReloadedOnKotlinChange()
throws MavenInvocationException, IOException, InterruptedException {
testDir = initProject("projects/classic-kotlin", "projects/project-classic-run-kotlin-change-remote");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<maven.compiler.source>11</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>11</maven.compiler.target>
<kotlin.version>1.4.32</kotlin.version>
<kotlin.version>1.5.20</kotlin.version>
</properties>
<dependencyManagement>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<maven.compiler.source>11</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>11</maven.compiler.target>
<kotlin.version>1.4.32</kotlin.version>
<kotlin.version>1.5.20</kotlin.version>
</properties>
<dependencyManagement>
<dependencies>
Expand Down

0 comments on commit 64bc781

Please sign in to comment.