Skip to content

Commit bd153cd

Browse files
authored
fix: add compatibility for GraalVM 22.2.0 (#1025)
1 parent 993b6f3 commit bd153cd

File tree

14 files changed

+46
-93
lines changed

14 files changed

+46
-93
lines changed

.kokoro/graalvm-native/linux/common.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ build_file: "cloud-sql-jdbc-socket-factory/.kokoro/trampoline.sh"
2525

2626
env_vars: {
2727
key: "TRAMPOLINE_IMAGE"
28-
value: "gcr.io/cloud-devrel-kokoro-resources/graalvm@sha256:69554e9e2f2d746cf4cef79fffa39ee39eba927fa000259a85ed680f7bc4fd66"
28+
value: "gcr.io/cloud-devrel-kokoro-resources/graalvm"
2929
}
3030

3131
# Tell the trampoline which tests to run.

core/pom.xml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,6 @@
110110
<artifactId>jnr-ffi</artifactId>
111111
<version>2.2.13</version>
112112
</dependency>
113-
<dependency>
114-
<!-- This dependency is "provided" scope. It doesn't affect library
115-
users' class paths -->
116-
<groupId>org.graalvm.nativeimage</groupId>
117-
<artifactId>svm</artifactId>
118-
<version>${graal-svm.version}</version>
119-
</dependency>
120113
<dependency>
121114
<groupId>org.graalvm.sdk</groupId>
122115
<artifactId>graal-sdk</artifactId>
@@ -205,11 +198,7 @@
205198
<!-- com.google.cloud.sql.nativeimage.CloudSqlFeature needs the GraalVM
206199
dependencies for compilation. The provided-scope dependencies do not add
207200
additional dependencies to library users. -->
208-
<dependency>
209-
<groupId>org.graalvm.nativeimage</groupId>
210-
<artifactId>svm</artifactId>
211-
<scope>provided</scope>
212-
</dependency>
201+
213202
<dependency>
214203
<groupId>org.graalvm.sdk</groupId>
215204
<artifactId>graal-sdk</artifactId>

core/src/main/java/com/google/cloud/sql/nativeimage/CloudSqlFeature.java

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,9 @@
1717
package com.google.cloud.sql.nativeimage;
1818

1919
import com.google.api.gax.nativeimage.NativeImageUtils;
20-
import com.oracle.svm.core.annotate.AutomaticFeature;
21-
import com.oracle.svm.core.configure.ResourcesRegistry;
22-
import org.graalvm.nativeimage.ImageSingletons;
2320
import org.graalvm.nativeimage.hosted.Feature;
2421
import org.graalvm.nativeimage.hosted.RuntimeClassInitialization;
2522
import org.graalvm.nativeimage.hosted.RuntimeReflection;
26-
import org.graalvm.nativeimage.impl.ConfigurationCondition;
2723

2824
/**
2925
* Registers GraalVM configuration for the Cloud SQL libraries.
@@ -32,7 +28,7 @@
3228
* href="https://www.graalvm.org/22.0/reference-manual/native-image/">GraalVM native image</a>
3329
* compilation.
3430
*/
35-
@AutomaticFeature
31+
3632
final class CloudSqlFeature implements Feature {
3733

3834
private static final String CLOUD_SQL_SOCKET_CLASS =
@@ -51,13 +47,6 @@ public void beforeAnalysis(BeforeAnalysisAccess access) {
5147
// The Core Cloud SQL Socket
5248
NativeImageUtils.registerClassForReflection(access, CLOUD_SQL_SOCKET_CLASS);
5349

54-
// Resources for Cloud SQL
55-
ResourcesRegistry resourcesRegistry = ImageSingletons.lookup(ResourcesRegistry.class);
56-
resourcesRegistry.addResources(
57-
ConfigurationCondition.alwaysTrue(), "\\Qcom.google.cloud.sql/project.properties\\E");
58-
resourcesRegistry.addResources(
59-
ConfigurationCondition.alwaysTrue(), "\\QMETA-INF/services/java.sql.Driver\\E");
60-
6150
// Register Hikari configs if used with Cloud SQL.
6251
if (access.findClassByName("com.zaxxer.hikari.HikariConfig") != null) {
6352
NativeImageUtils.registerClassForReflection(access, "com.zaxxer.hikari.HikariConfig");
@@ -83,8 +72,6 @@ public void beforeAnalysis(BeforeAnalysisAccess access) {
8372

8473
NativeImageUtils.registerConstructorsForReflection(
8574
access, "com.mysql.cj.conf.url.SingleConnectionUrl");
86-
resourcesRegistry.addResources(ConfigurationCondition.alwaysTrue(),
87-
"\\Qcom/mysql/cj/util/TimeZoneMapping.properties\\E");
8875

8976
// for mysql-j-5
9077
NativeImageUtils.registerConstructorsForReflection(
@@ -118,14 +105,7 @@ public void beforeAnalysis(BeforeAnalysisAccess access) {
118105

119106
// JDBC classes create socket connections which must be initialized at run time.
120107
RuntimeClassInitialization.initializeAtRunTime("com.mysql.cj.jdbc");
121-
122-
// Additional MySQL resources.
123-
resourcesRegistry.addResourceBundles(
124-
ConfigurationCondition.alwaysTrue(), "com.mysql.cj.LocalizedErrorMessages");
125-
resourcesRegistry.addResourceBundles(
126-
ConfigurationCondition.alwaysTrue(), "com.mysql.jdbc.LocalizedErrorMessages");
127108
}
128-
129109
// This Netty class should be initialized at runtime
130110
// https://github.com/netty/netty/issues/11638
131111
Class<?> bouncyCastleAlpnSslUtils =
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Args =\
2+
--features=com.google.cloud.sql.nativeimage.CloudSqlFeature
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"resources":[
3+
{"pattern":"\\Qcom.google.cloud.sql/project.properties\\E"},
4+
{"pattern":"\\QMETA-INF/services/java.sql.Driver\\E"},
5+
{"pattern":"\\Qcom/mysql/cj/util/TimeZoneMapping.properties\\E"}
6+
],
7+
"bundles": [
8+
{"name":"com.mysql.cj.LocalizedErrorMessages"},
9+
{"name":"com.mysql.jdbc.LocalizedErrorMessages"}
10+
]
11+
}

jdbc/mysql-j-5/pom.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,6 @@
103103
<artifactId>jnr-ffi</artifactId>
104104
<version>2.2.13</version>
105105
</dependency>
106-
<dependency>
107-
<!-- This dependency is "provided" scope. It doesn't affect library
108-
users' class paths -->
109-
<groupId>org.graalvm.nativeimage</groupId>
110-
<artifactId>svm</artifactId>
111-
<version>${graal-svm.version}</version>
112-
</dependency>
113106
<dependency>
114107
<groupId>org.graalvm.sdk</groupId>
115108
<artifactId>graal-sdk</artifactId>

jdbc/mysql-j-8/pom.xml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,6 @@
102102
<artifactId>google-http-client-gson</artifactId>
103103
<version>1.42.3</version>
104104
</dependency>
105-
<dependency>
106-
<!-- This dependency is "provided" scope. It doesn't affect library
107-
users' class paths -->
108-
<groupId>org.graalvm.nativeimage</groupId>
109-
<artifactId>svm</artifactId>
110-
<version>${graal-svm.version}</version>
111-
</dependency>
112105
<dependency>
113106
<groupId>org.graalvm.sdk</groupId>
114107
<artifactId>graal-sdk</artifactId>
@@ -164,6 +157,20 @@
164157
</dependency>
165158
</dependencies>
166159
</profile>
160+
<!-- Upgrading to v0.9.12 of the native maven plugin leaves
161+
provided scope dependencies out of the classpath, so adding these
162+
drivers back in for the native profile is a workaround.
163+
-->
164+
<profile>
165+
<id>native</id>
166+
<dependencies>
167+
<dependency>
168+
<groupId>mysql</groupId>
169+
<artifactId>mysql-connector-java</artifactId>
170+
<version>8.0.17</version>
171+
</dependency>
172+
</dependencies>
173+
</profile>
167174
</profiles>
168175

169176
</project>

jdbc/postgres/pom.xml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,6 @@
101101
<artifactId>google-http-client-gson</artifactId>
102102
<version>1.42.3</version>
103103
</dependency>
104-
<dependency>
105-
<!-- This dependency is "provided" scope. It doesn't affect library
106-
users' class paths -->
107-
<groupId>org.graalvm.nativeimage</groupId>
108-
<artifactId>svm</artifactId>
109-
<version>${graal-svm.version}</version>
110-
</dependency>
111104
<dependency>
112105
<groupId>org.graalvm.sdk</groupId>
113106
<artifactId>graal-sdk</artifactId>
@@ -163,6 +156,20 @@
163156
</dependency>
164157
</dependencies>
165158
</profile>
159+
<!-- Upgrading to v0.9.12 of the native maven plugin leaves
160+
provided scope dependencies out of the classpath, so adding these
161+
drivers back in for the native profile is a workaround.
162+
-->
163+
<profile>
164+
<id>native</id>
165+
<dependencies>
166+
<dependency>
167+
<groupId>org.postgresql</groupId>
168+
<artifactId>postgresql</artifactId>
169+
<version>42.5.0</version>
170+
</dependency>
171+
</dependencies>
172+
</profile>
166173
</profiles>
167174

168175
</project>

jdbc/sqlserver/pom.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,6 @@
101101
<artifactId>google-http-client-gson</artifactId>
102102
<version>1.42.3</version>
103103
</dependency>
104-
<dependency>
105-
<!-- This dependency is "provided" scope. It doesn't affect library
106-
users' class paths -->
107-
<groupId>org.graalvm.nativeimage</groupId>
108-
<artifactId>svm</artifactId>
109-
<version>${graal-svm.version}</version>
110-
</dependency>
111104
<dependency>
112105
<groupId>org.graalvm.sdk</groupId>
113106
<artifactId>graal-sdk</artifactId>

pom.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@
7272
<properties>
7373
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
7474
<javac.version>9+181-r4173-1</javac.version>
75-
<native-image.version>0.9.11</native-image.version>
76-
<graal-sdk.version>21.3.4</graal-sdk.version>
77-
<graal-svm.version>22.0.0.2</graal-svm.version>
75+
<native-image.version>0.9.16</native-image.version>
76+
<graal-sdk.version>22.2.0</graal-sdk.version>
7877
<assembly.skipAssembly>true</assembly.skipAssembly>
7978
</properties>
8079

0 commit comments

Comments
 (0)