Skip to content

Commit

Permalink
Upgrade svm, annotation for reflection (#2070)
Browse files Browse the repository at this point in the history
* Upgrade svm libraries.
Annotation for reflection in native image.

Signed-off-by: Tomas Langer <tomas.langer@oracle.com>

* Missed required class.
Signed-off-by: Tomas Langer <tomas.langer@oracle.com>

Signed-off-by: Tomas Langer <tomas.langer@oracle.com>
  • Loading branch information
tomas-langer authored Jun 19, 2020
1 parent 05e89c5 commit 093ec0d
Show file tree
Hide file tree
Showing 10 changed files with 330 additions and 136 deletions.
39 changes: 39 additions & 0 deletions common/common/src/main/java/io/helidon/common/Reflected.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2020 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.helidon.common;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* A type annotated with this annotation will be added to native image with reflection support for all methods
* and fields (including private).
* A method or field annotated with this method will be added for reflection.
* <p>
* This is an alternative to GraalVM native-image's {@code reflect-config.json} file, specific to Helidon.
* Processing of this annotation requires {@code io.helidon.integrations.graal:helidon-graal-native-image-extension}
* on the classpath when building native image.
* <p>
* Constructors annotated with this annotation would only be added for reflection if either a field
* or a method is annotated as well (this is current limitation of API of native image).
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR})
public @interface Reflected {
}
4 changes: 2 additions & 2 deletions dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<version.lib.failsafe>2.3.1</version.lib.failsafe>
<version.lib.google-api-client>1.30.5</version.lib.google-api-client>
<version.lib.google-error-prone>2.3.3</version.lib.google-error-prone>
<version.lib.graalvm>19.2.0</version.lib.graalvm>
<version.lib.graalvm>20.0.0</version.lib.graalvm>
<version.lib.grpc>1.27.1</version.lib.grpc>
<version.lib.guava>28.1-jre</version.lib.guava>
<version.lib.h2>1.4.199</version.lib.h2>
Expand Down Expand Up @@ -914,7 +914,7 @@
<version>${version.lib.graalvm}</version>
</dependency>
<dependency>
<groupId>com.oracle.substratevm</groupId>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>svm</artifactId>
<version>${version.lib.graalvm}</version>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
*/
package io.helidon.examples.dbclient.pokemons;

import io.helidon.common.Reflected;

/**
* POJO representing Pokemon.
*/
@Reflected
public class Pokemon {

private int id;
private String name;
private int idType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*/
public final class PokemonMain {

/** MongoDB configuration. Default configuration file {@code appliaction.yaml} contains MySQL/JDBC configuration. */
/** MongoDB configuration. Default configuration file {@code appliaction.yaml} contains JDBC configuration. */
private static final String MONGO_CFG = "mongo.yaml";

/** Whether MongoDB support is selected. */
Expand All @@ -63,7 +63,7 @@ public static void main(final String[] args) throws IOException {
System.out.println("MongoDB database selected");
mongo = true;
} else {
System.out.println("MySQL/JDBC database selected");
System.out.println("JDBC database selected");
mongo = false;
}
startServer();
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions integrations/db/h2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<properties>
<!--
To build javadocs we need to have a valid module-info file. But com.oracle.substratevm:svm appears
To build javadocs we need to have a valid module-info file. But org.graalvm.nativeimage:svm appears
to have a bad module-info. So for now we skip generating javadocs.
-->
<maven.javadoc.skip>true</maven.javadoc.skip>
Expand All @@ -44,7 +44,7 @@
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.substratevm</groupId>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>svm</artifactId>
<scope>provided</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"classes": [
"org.hibernate.dialect.Oracle10gDialect"
"org.hibernate.dialect.Oracle10gDialect",
"oracle.jdbc.logging.annotations.Supports",
"oracle.jdbc.logging.annotations.Feature"
]
}
2 changes: 1 addition & 1 deletion integrations/graal/mp-native-image-extension/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oracle.substratevm</groupId>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>svm</artifactId>
<scope>provided</scope>
</dependency>
Expand Down
4 changes: 2 additions & 2 deletions integrations/graal/native-image-extension/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

<properties>
<!--
To build javadocs we need to have a valid module-info file. But com.oracle.substratevm:svm appears
To build javadocs we need to have a valid module-info file. But org.graalvm.nativeimage:svm appears
to have a bad module-info. So for now we skip generating javadocs.
-->
<maven.javadoc.skip>true</maven.javadoc.skip>
Expand All @@ -55,7 +55,7 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oracle.substratevm</groupId>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>svm</artifactId>
<scope>provided</scope>
</dependency>
Expand Down
Loading

0 comments on commit 093ec0d

Please sign in to comment.