diff --git a/.github/release-please.yml b/.github/release-please.yml index 8a0e92768a..a24a02defc 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -14,3 +14,7 @@ branches: handleGHRelease: true releaseType: java-backport branch: 2.2.x + - bumpMinorPreMajor: true + handleGHRelease: true + releaseType: java-backport + branch: 2.6.x diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index be62d8420f..20770a28dd 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -63,6 +63,21 @@ branchProtectionRules: - 'Kokoro - Test: Integration' - cla/google - OwlBot Post Processor + - pattern: 2.6.x + isAdminEnforced: true + requiredApprovingReviewCount: 1 + requiresCodeOwnerReviews: true + requiresStrictStatusChecks: false + requiredStatusCheckContexts: + - dependencies (8) + - dependencies (11) + - lint + - clirr + - units (8) + - units (11) + - 'Kokoro - Test: Integration' + - cla/google + - OwlBot Post Processor permissionRules: - team: yoshi-admins permission: admin diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d7871b9fb..df3f6c30cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,36 @@ # Changelog +## [2.7.0](https://github.com/googleapis/java-core/compare/v2.6.1...v2.7.0) (2022-05-18) + + +### Features + +* **java:** remove native-image-support module ([#820](https://github.com/googleapis/java-core/issues/820)) ([a53ef6d](https://github.com/googleapis/java-core/commit/a53ef6d7ba05eeba82998378455f0aea58f24381)) +* next release from main branch is 2.7.0 ([#807](https://github.com/googleapis/java-core/issues/807)) ([5a2c608](https://github.com/googleapis/java-core/commit/5a2c608e375d15ec83ca71232627bce1f167e750)) + + +### Bug Fixes + +* remove native-image-support module from version.txt ([#822](https://github.com/googleapis/java-core/issues/822)) ([92e7efc](https://github.com/googleapis/java-core/commit/92e7efc4974911f7ce30021a280c9002a44dab47)) + + +### Dependencies + +* update dependency com.google.api-client:google-api-client-bom to v1.34.1 ([#823](https://github.com/googleapis/java-core/issues/823)) ([71105c6](https://github.com/googleapis/java-core/commit/71105c64918d6444e321fa3de5fc402e577ebc7d)) +* update dependency com.google.api:api-common to v2.2.0 ([#827](https://github.com/googleapis/java-core/issues/827)) ([05a02d6](https://github.com/googleapis/java-core/commit/05a02d6b16cb06b9f1dea0814912e5a32913fca8)) +* update dependency com.google.api:gax-bom to v2.17.0 ([#826](https://github.com/googleapis/java-core/issues/826)) ([c90188e](https://github.com/googleapis/java-core/commit/c90188e9a94ae71d71105d908173f1bd7e77c1cb)) +* update dependency com.google.api:gax-bom to v2.18.0 ([#829](https://github.com/googleapis/java-core/issues/829)) ([5537e7f](https://github.com/googleapis/java-core/commit/5537e7f80d5db94038b24a393e310120fab62e8c)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.3.2 ([#805](https://github.com/googleapis/java-core/issues/805)) ([493ac03](https://github.com/googleapis/java-core/commit/493ac038d3ca9f603cd47969fde0da68a1f9bfd0)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.3.3 ([#814](https://github.com/googleapis/java-core/issues/814)) ([e809baa](https://github.com/googleapis/java-core/commit/e809baa69672d3eca2dc348f55615dc072a8fbe3)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.3.4 ([#825](https://github.com/googleapis/java-core/issues/825)) ([5ce12ee](https://github.com/googleapis/java-core/commit/5ce12ee0c10e2bdb5981e6ca02966d7eb802ca6c)) +* update dependency com.google.auth:google-auth-library-bom to v1.7.0 ([#828](https://github.com/googleapis/java-core/issues/828)) ([2abca2c](https://github.com/googleapis/java-core/commit/2abca2c135ba2337d546d5c97bcdd5901e91301a)) +* update dependency com.google.cloud:native-image-support to v0.14.0 ([#824](https://github.com/googleapis/java-core/issues/824)) ([997a34a](https://github.com/googleapis/java-core/commit/997a34a15a59bb1818fff3d1fbce195a05d12da3)) +* update dependency com.google.errorprone:error_prone_annotations to v2.13.1 ([#806](https://github.com/googleapis/java-core/issues/806)) ([9fc5811](https://github.com/googleapis/java-core/commit/9fc5811eae52288acd9fb0b967e5737848fe7c5e)) +* update dependency com.google.http-client:google-http-client-bom to v1.41.8 ([#821](https://github.com/googleapis/java-core/issues/821)) ([c7e3d6e](https://github.com/googleapis/java-core/commit/c7e3d6ef437d9f85dab450b54d63f7218b89788b)) +* update dependency com.google.protobuf:protobuf-bom to v3.20.1 ([#813](https://github.com/googleapis/java-core/issues/813)) ([a9c8c92](https://github.com/googleapis/java-core/commit/a9c8c92086c0266e14f86a957944c0cc4ab26ee6)) +* update dependency io.grpc:grpc-bom to v1.46.0 ([#815](https://github.com/googleapis/java-core/issues/815)) ([03c9bfe](https://github.com/googleapis/java-core/commit/03c9bfe4210a6c3995adf89be28b7c8aab402fb3)) +* update opencensus.version to v0.31.1 ([#819](https://github.com/googleapis/java-core/issues/819)) ([1800d3a](https://github.com/googleapis/java-core/commit/1800d3aa3ff7315947681b648f822f2cf9656a3b)) + ### [2.6.1](https://github.com/googleapis/java-core/compare/v2.6.0...v2.6.1) (2022-04-14) diff --git a/google-cloud-core-bom/pom.xml b/google-cloud-core-bom/pom.xml index 92aaa71988..9f907f9ead 100644 --- a/google-cloud-core-bom/pom.xml +++ b/google-cloud-core-bom/pom.xml @@ -3,12 +3,12 @@ 4.0.0 com.google.cloud google-cloud-core-bom - 2.6.1 + 2.7.0 pom com.google.cloud google-cloud-shared-config - 1.3.2 + 1.4.0 Google Cloud Core @@ -63,22 +63,22 @@ com.google.cloud google-cloud-core - 2.6.1 + 2.7.0 com.google.cloud google-cloud-core-grpc - 2.6.1 + 2.7.0 com.google.cloud google-cloud-core-http - 2.6.1 + 2.7.0 com.google.cloud native-image-support - 0.13.1 + 0.14.0 diff --git a/google-cloud-core-grpc/pom.xml b/google-cloud-core-grpc/pom.xml index 313a0a281c..31cb74ba13 100644 --- a/google-cloud-core-grpc/pom.xml +++ b/google-cloud-core-grpc/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-core-grpc - 2.6.1 + 2.7.0 jar Google Cloud Core gRPC https://github.com/googleapis/java-core @@ -13,7 +13,7 @@ com.google.cloud google-cloud-core-parent - 2.6.1 + 2.7.0 google-cloud-core-grpc diff --git a/google-cloud-core-http/pom.xml b/google-cloud-core-http/pom.xml index 634d6b360d..3df47c4c84 100644 --- a/google-cloud-core-http/pom.xml +++ b/google-cloud-core-http/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-core-http - 2.6.1 + 2.7.0 jar Google Cloud Core HTTP https://github.com/googleapis/java-core @@ -13,7 +13,7 @@ com.google.cloud google-cloud-core-parent - 2.6.1 + 2.7.0 google-cloud-core-http diff --git a/google-cloud-core/pom.xml b/google-cloud-core/pom.xml index 8ec9ef76d9..e9c60d282f 100644 --- a/google-cloud-core/pom.xml +++ b/google-cloud-core/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-core - 2.6.1 + 2.7.0 jar Google Cloud Core https://github.com/googleapis/java-core @@ -13,7 +13,7 @@ com.google.cloud google-cloud-core-parent - 2.6.1 + 2.7.0 google-cloud-core diff --git a/native-image-support/pom.xml b/native-image-support/pom.xml deleted file mode 100644 index 86b9c6cb32..0000000000 --- a/native-image-support/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - 4.0.0 - Google Cloud Native Image Support - com.google.cloud - native-image-support - 0.13.1 - jar - - - google-cloud-core-parent - com.google.cloud - 2.6.1 - - - - Core gRPC module for the google-cloud. - - - - - - org.graalvm.nativeimage - svm - provided - - - - org.graalvm.sdk - graal-sdk - provided - - - \ No newline at end of file diff --git a/native-image-support/src/main/java/com/google/cloud/nativeimage/features/NativeImageUtils.java b/native-image-support/src/main/java/com/google/cloud/nativeimage/features/NativeImageUtils.java deleted file mode 100644 index 8b19f4b84f..0000000000 --- a/native-image-support/src/main/java/com/google/cloud/nativeimage/features/NativeImageUtils.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * 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 - * - * https://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 com.google.cloud.nativeimage.features; - -import java.io.IOException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.net.JarURLConnection; -import java.net.URL; -import java.net.URLConnection; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.List; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import java.util.logging.Logger; -import org.graalvm.nativeimage.hosted.Feature.FeatureAccess; -import org.graalvm.nativeimage.hosted.RuntimeReflection; - -/** Internal class offering helper methods for registering methods/classes for reflection. */ -public class NativeImageUtils { - - private static final Logger LOGGER = Logger.getLogger(NativeImageUtils.class.getName()); - - /** Returns the method of a class or fails if it is not present. */ - public static Method getMethodOrFail(Class clazz, String methodName, Class... params) { - try { - return clazz.getDeclaredMethod(methodName, params); - } catch (NoSuchMethodException e) { - throw new RuntimeException( - "Failed to find method " + methodName + " for class " + clazz.getName(), e); - } - } - - /** Registers a class for reflective construction via its default constructor. */ - public static void registerForReflectiveInstantiation(FeatureAccess access, String className) { - Class clazz = access.findClassByName(className); - if (clazz != null) { - RuntimeReflection.register(clazz); - RuntimeReflection.registerForReflectiveInstantiation(clazz); - } else { - LOGGER.warning( - "Failed to find " + className + " on the classpath for reflective instantiation."); - } - } - - /** Registers all constructors of a class for reflection. */ - public static void registerConstructorsForReflection(FeatureAccess access, String name) { - Class clazz = access.findClassByName(name); - if (clazz != null) { - RuntimeReflection.register(clazz); - RuntimeReflection.register(clazz.getDeclaredConstructors()); - } else { - LOGGER.warning("Failed to find " + name + " on the classpath for reflection."); - } - } - - /** Registers an entire class for reflection use. */ - public static void registerClassForReflection(FeatureAccess access, String name) { - Class clazz = access.findClassByName(name); - if (clazz != null) { - RuntimeReflection.register(clazz); - RuntimeReflection.register(clazz.getDeclaredConstructors()); - RuntimeReflection.register(clazz.getDeclaredFields()); - RuntimeReflection.register(clazz.getDeclaredMethods()); - } else { - LOGGER.warning("Failed to find " + name + " on the classpath for reflection."); - } - } - - /** - * Registers the transitive class hierarchy of the provided {@code className} for reflection. - * - *

The transitive class hierarchy contains the class itself and its transitive set of - * *non-private* nested subclasses. - */ - public static void registerClassHierarchyForReflection(FeatureAccess access, String className) { - Class clazz = access.findClassByName(className); - if (clazz != null) { - registerClassForReflection(access, className); - for (Class nestedClass : clazz.getDeclaredClasses()) { - if (!Modifier.isPrivate(nestedClass.getModifiers())) { - registerClassHierarchyForReflection(access, nestedClass.getName()); - } - } - } else { - LOGGER.warning("Failed to find " + className + " on the classpath for reflection."); - } - } - - /** Registers a class for unsafe reflective field access. */ - public static void registerForUnsafeFieldAccess( - FeatureAccess access, String className, String... fields) { - Class clazz = access.findClassByName(className); - if (clazz != null) { - RuntimeReflection.register(clazz); - for (String fieldName : fields) { - try { - RuntimeReflection.register(clazz.getDeclaredField(fieldName)); - } catch (NoSuchFieldException ex) { - LOGGER.warning("Failed to register field " + fieldName + " for class " + className); - LOGGER.warning(ex.getMessage()); - } - } - } else { - LOGGER.warning( - "Failed to find " - + className - + " on the classpath for unsafe fields access registration."); - } - } - - /** Registers all the classes under the specified package for reflection. */ - public static void registerPackageForReflection(FeatureAccess access, String packageName) { - ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - - try { - String path = packageName.replace('.', '/'); - - Enumeration resources = classLoader.getResources(path); - while (resources.hasMoreElements()) { - URL url = resources.nextElement(); - - URLConnection connection = url.openConnection(); - if (connection instanceof JarURLConnection) { - List classes = findClassesInJar((JarURLConnection) connection, packageName); - for (String className : classes) { - registerClassHierarchyForReflection(access, className); - } - } - } - } catch (IOException e) { - throw new RuntimeException("Failed to load classes under package name.", e); - } - } - - private static List findClassesInJar(JarURLConnection urlConnection, String packageName) - throws IOException { - - List result = new ArrayList<>(); - - final JarFile jarFile = urlConnection.getJarFile(); - final Enumeration entries = jarFile.entries(); - - while (entries.hasMoreElements()) { - JarEntry entry = entries.nextElement(); - String entryName = entry.getName(); - - if (entryName.endsWith(".class")) { - String javaClassName = entryName.replace(".class", "").replace('/', '.'); - - if (javaClassName.startsWith(packageName)) { - result.add(javaClassName); - } - } - } - - return result; - } -} diff --git a/native-image-support/src/main/java/com/google/cloud/nativeimage/features/clients/CloudFunctionsFeature.java b/native-image-support/src/main/java/com/google/cloud/nativeimage/features/clients/CloudFunctionsFeature.java deleted file mode 100644 index 7b7eaaebaf..0000000000 --- a/native-image-support/src/main/java/com/google/cloud/nativeimage/features/clients/CloudFunctionsFeature.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * 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 - * - * https://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 com.google.cloud.nativeimage.features.clients; - -import static com.google.cloud.nativeimage.features.NativeImageUtils.registerClassForReflection; -import static com.google.cloud.nativeimage.features.NativeImageUtils.registerClassHierarchyForReflection; - -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.configure.ResourcesRegistry; -import java.io.IOException; -import java.lang.reflect.Modifier; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.nio.file.Path; -import java.util.Arrays; -import java.util.Enumeration; -import java.util.List; -import java.util.function.Consumer; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import java.util.stream.Collectors; -import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; -import org.graalvm.nativeimage.hosted.RuntimeReflection; - -/** A feature which registers reflective usages of the Cloud Functions library. */ -@AutomaticFeature -final class CloudFunctionsFeature implements Feature { - - private static final String FUNCTION_INVOKER_CLASS = - "com.google.cloud.functions.invoker.runner.Invoker"; - - private static final List FUNCTIONS_CLASSES = - Arrays.asList( - "com.google.cloud.functions.HttpFunction", - "com.google.cloud.functions.RawBackgroundFunction", - "com.google.cloud.functions.BackgroundFunction"); - - @Override - public void beforeAnalysis(BeforeAnalysisAccess access) { - Class invokerClass = access.findClassByName(FUNCTION_INVOKER_CLASS); - if (invokerClass != null) { - // JCommander libraries - registerClassForReflection(access, "com.beust.jcommander.converters.StringConverter"); - registerClassForReflection(access, "com.beust.jcommander.validators.NoValidator"); - registerClassForReflection(access, "com.beust.jcommander.validators.NoValueValidator"); - - // Jetty libraries - registerClassForReflection(access, "org.eclipse.jetty.http.HttpTokens"); - registerClassForReflection(access, "org.eclipse.jetty.util.TypeUtil"); - - // Cloud Functions core - registerClassForReflection( - access, "com.google.cloud.functions.invoker.runner.Invoker$Options"); - - // Register Jetty Resources. - ResourcesRegistry resourcesRegistry = ImageSingletons.lookup(ResourcesRegistry.class); - resourcesRegistry.addResources( - "\\QMETA-INF/services/org.eclipse.jetty.http.HttpFieldPreEncoder\\E"); - resourcesRegistry.addResources("\\Qorg/eclipse/jetty/http/encoding.properties\\E"); - resourcesRegistry.addResources("\\Qorg/eclipse/jetty/http/mime.properties\\E"); - resourcesRegistry.addResources("\\Qorg/eclipse/jetty/version/build.properties\\E"); - resourcesRegistry.addResourceBundles("javax.servlet.LocalStrings"); - resourcesRegistry.addResourceBundles("javax.servlet.http.LocalStrings"); - - // Register user-implemented Function classes - List> functionClasses = - FUNCTIONS_CLASSES.stream() - .map(name -> access.findClassByName(name)) - .collect(Collectors.toList()); - - scanJarClasspath( - access, - clazz -> { - boolean isFunctionSubtype = - functionClasses.stream() - .anyMatch( - function -> - function.isAssignableFrom(clazz) - && !Modifier.isAbstract(clazz.getModifiers())); - - if (isFunctionSubtype) { - RuntimeReflection.register(clazz); - RuntimeReflection.register(clazz.getDeclaredConstructors()); - RuntimeReflection.register(clazz.getDeclaredMethods()); - - // This part is to register the parameterized class of BackgroundFunctions - // for reflection; i.e. register type T in BackgroundFunction - for (Type type : clazz.getGenericInterfaces()) { - if (type instanceof ParameterizedType) { - ParameterizedType paramType = (ParameterizedType) type; - for (Type argument : paramType.getActualTypeArguments()) { - registerClassHierarchyForReflection(access, argument.getTypeName()); - } - } - } - } - }); - } - } - - /** - * Scan the JAR classpath for classes. The {@code classProcessorFunction} is run once for each - * class in the classpath. - */ - private static void scanJarClasspath( - FeatureAccess access, Consumer> classProcessorCallback) { - - List classPath = access.getApplicationClassPath(); - try { - for (Path path : classPath) { - JarFile jarFile = new JarFile(path.toFile()); - Enumeration entries = jarFile.entries(); - - while (entries.hasMoreElements()) { - JarEntry jarEntry = entries.nextElement(); - String fileName = jarEntry.getName(); - if (fileName.endsWith(".class")) { - String className = fileName.substring(0, fileName.length() - 6).replaceAll("/", "."); - - Class clazz = access.findClassByName(className); - if (clazz != null) { - classProcessorCallback.accept(clazz); - } - } - } - } - } catch (IOException e) { - throw new RuntimeException("Failed to read classpath: ", e); - } - } -} diff --git a/native-image-support/src/main/java/com/google/cloud/nativeimage/features/clients/CloudSqlFeature.java b/native-image-support/src/main/java/com/google/cloud/nativeimage/features/clients/CloudSqlFeature.java deleted file mode 100644 index 48b4c1e4ef..0000000000 --- a/native-image-support/src/main/java/com/google/cloud/nativeimage/features/clients/CloudSqlFeature.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * 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 - * - * https://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 com.google.cloud.nativeimage.features.clients; - -import com.google.cloud.nativeimage.features.NativeImageUtils; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.configure.ResourcesRegistry; -import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; -import org.graalvm.nativeimage.hosted.RuntimeClassInitialization; -import org.graalvm.nativeimage.hosted.RuntimeReflection; - -/** Registers GraalVM configuration for the Cloud SQL libraries for MySQL and Postgres. */ -@AutomaticFeature -final class CloudSqlFeature implements Feature { - - private static final String CLOUD_SQL_SOCKET_CLASS = - "com.google.cloud.sql.core.CoreSocketFactory"; - - private static final String POSTGRES_SOCKET_CLASS = "com.google.cloud.sql.postgres.SocketFactory"; - - private static final String MYSQL_SOCKET_CLASS = "com.google.cloud.sql.mysql.SocketFactory"; - - @Override - public void beforeAnalysis(BeforeAnalysisAccess access) { - if (access.findClassByName(CLOUD_SQL_SOCKET_CLASS) == null) { - return; - } - - // The Core Cloud SQL Socket - NativeImageUtils.registerClassForReflection(access, CLOUD_SQL_SOCKET_CLASS); - - // Resources for Cloud SQL - ResourcesRegistry resourcesRegistry = ImageSingletons.lookup(ResourcesRegistry.class); - resourcesRegistry.addResources("\\Qcom.google.cloud.sql/project.properties\\E"); - resourcesRegistry.addResources("\\QMETA-INF/services/java.sql.Driver\\E"); - - // Register Hikari configs if used with Cloud SQL. - if (access.findClassByName("com.zaxxer.hikari.HikariConfig") != null) { - NativeImageUtils.registerClassForReflection(access, "com.zaxxer.hikari.HikariConfig"); - - RuntimeReflection.register( - access.findClassByName("[Lcom.zaxxer.hikari.util.ConcurrentBag$IConcurrentBagEntry;")); - - RuntimeReflection.register(access.findClassByName("[Ljava.sql.Statement;")); - } - - // Register PostgreSQL driver config. - if (access.findClassByName(POSTGRES_SOCKET_CLASS) != null) { - NativeImageUtils.registerClassForReflection( - access, "com.google.cloud.sql.postgres.SocketFactory"); - NativeImageUtils.registerClassForReflection(access, "org.postgresql.PGProperty"); - } - - // Register MySQL driver config. - if (access.findClassByName(MYSQL_SOCKET_CLASS) != null) { - NativeImageUtils.registerClassForReflection(access, MYSQL_SOCKET_CLASS); - - NativeImageUtils.registerConstructorsForReflection( - access, "com.mysql.cj.conf.url.SingleConnectionUrl"); - - NativeImageUtils.registerConstructorsForReflection(access, "com.mysql.cj.log.StandardLogger"); - - access.registerSubtypeReachabilityHandler( - (duringAccess, exceptionClass) -> - NativeImageUtils.registerClassForReflection(duringAccess, exceptionClass.getName()), - access.findClassByName("com.mysql.cj.exceptions.CJException")); - - // JDBC classes create socket connections which must be initialized at run time. - RuntimeClassInitialization.initializeAtRunTime("com.mysql.cj.jdbc"); - - // Additional MySQL resources. - resourcesRegistry.addResourceBundles("com.mysql.cj.LocalizedErrorMessages"); - } - } -} diff --git a/native-image-support/src/main/java/com/google/cloud/nativeimage/features/clients/SpannerFeature.java b/native-image-support/src/main/java/com/google/cloud/nativeimage/features/clients/SpannerFeature.java deleted file mode 100644 index 956f368dac..0000000000 --- a/native-image-support/src/main/java/com/google/cloud/nativeimage/features/clients/SpannerFeature.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * 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 - * - * https://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 com.google.cloud.nativeimage.features.clients; - -import com.google.cloud.nativeimage.features.NativeImageUtils; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.configure.ResourcesRegistry; -import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; -import org.graalvm.nativeimage.impl.ConfigurationCondition; - -/** Registers Spanner library classes for reflection. */ -@AutomaticFeature -final class SpannerFeature implements Feature { - - private static final String SPANNER_CLASS = "com.google.spanner.v1.SpannerGrpc"; - private static final String SPANNER_TEST_CLASS = "com.google.cloud.spanner.GceTestEnvConfig"; - private static final String MOCK_CLASS = "com.google.cloud.spanner.MockDatabaseAdminServiceImpl"; - private static final String CLIENT_SIDE_IMPL_CLASS = - "com.google.cloud.spanner.connection.ClientSideStatementImpl"; - private static final String CLIENT_SIDE_VALUE_CONVERTER = - "com.google.cloud.spanner.connection.ClientSideStatementValueConverters"; - private static final String CONNECTION_IMPL = - "com.google.cloud.spanner.connection.ConnectionImpl"; - private static final String CLIENT_SIDE_STATEMENTS = - "com.google.cloud.spanner.connection.ClientSideStatements"; - private static final String CONNECTION_STATEMENT_EXECUTOR = - "com.google.cloud.spanner.connection.ConnectionStatementExecutor"; - private static final String CLIENT_SIDE_STATEMENT_NO_PARAM_EXECUTOR = - "com.google.cloud.spanner.connection.ClientSideStatementNoParamExecutor"; - private static final String CLIENT_SIDE_STATEMENT_SET_EXECUTOR = - "com.google.cloud.spanner.connection.ClientSideStatementSetExecutor"; - private static final String ABSTRACT_STATEMENT_PARSER = - "com.google.cloud.spanner.connection.AbstractStatementParser"; - private static final String STATEMENT_PARSER = - "com.google.cloud.spanner.connection.SpannerStatementParser"; - - @Override - public void beforeAnalysis(BeforeAnalysisAccess access) { - registerSpannerTestClasses(access); - if (access.findClassByName(CLIENT_SIDE_IMPL_CLASS) != null) { - NativeImageUtils.registerClassHierarchyForReflection(access, CLIENT_SIDE_IMPL_CLASS); - } - if (access.findClassByName(CLIENT_SIDE_STATEMENT_NO_PARAM_EXECUTOR) != null) { - NativeImageUtils.registerClassForReflection(access, CLIENT_SIDE_STATEMENT_NO_PARAM_EXECUTOR); - } - if (access.findClassByName(CLIENT_SIDE_STATEMENT_SET_EXECUTOR) != null) { - NativeImageUtils.registerClassForReflection(access, CLIENT_SIDE_STATEMENT_SET_EXECUTOR); - } - if (access.findClassByName(CLIENT_SIDE_VALUE_CONVERTER) != null) { - NativeImageUtils.registerClassHierarchyForReflection(access, CLIENT_SIDE_VALUE_CONVERTER); - } - if (access.findClassByName(CLIENT_SIDE_STATEMENTS) != null) { - NativeImageUtils.registerClassForReflection(access, CLIENT_SIDE_STATEMENTS); - } - if (access.findClassByName(CONNECTION_STATEMENT_EXECUTOR) != null) { - NativeImageUtils.registerClassForReflection(access, CONNECTION_STATEMENT_EXECUTOR); - } - if (access.findClassByName(CONNECTION_IMPL) != null) { - NativeImageUtils.registerClassForReflection(access, CONNECTION_IMPL); - } - if (access.findClassByName(ABSTRACT_STATEMENT_PARSER) != null) { - NativeImageUtils.registerClassHierarchyForReflection(access, ABSTRACT_STATEMENT_PARSER); - } - if (access.findClassByName(STATEMENT_PARSER) != null) { - NativeImageUtils.registerConstructorsForReflection(access, STATEMENT_PARSER); - } - - Class spannerClass = access.findClassByName(SPANNER_CLASS); - if (spannerClass != null) { - NativeImageUtils.registerClassHierarchyForReflection( - access, "com.google.spanner.admin.database.v1.Database"); - NativeImageUtils.registerClassHierarchyForReflection( - access, "com.google.spanner.admin.instance.v1.Instance"); - NativeImageUtils.registerClassForReflection( - access, "com.google.spanner.admin.database.v1.RestoreInfo"); - - // Resources - ResourcesRegistry resourcesRegistry = ImageSingletons.lookup(ResourcesRegistry.class); - resourcesRegistry.addResources( - ConfigurationCondition.alwaysTrue(), - "\\Qcom/google/cloud/spanner/connection/ClientSideStatements.json\\E"); - resourcesRegistry.addResources( - "\\Qcom/google/cloud/spanner/spi/v1/grpc-gcp-apiconfig.json\\E"); - resourcesRegistry.addResources( - ConfigurationCondition.alwaysTrue(), - "\\Qcom/google/cloud/spanner/connection/ITSqlScriptTest_TestQueryOptions.sql\\E"); - } - } - - private void registerSpannerTestClasses(BeforeAnalysisAccess access) { - Class spannerTestClass = access.findClassByName(SPANNER_TEST_CLASS); - if (spannerTestClass != null) { - NativeImageUtils.registerConstructorsForReflection(access, SPANNER_TEST_CLASS); - } - Class mockClass = access.findClassByName(MOCK_CLASS); - if (mockClass != null) { - NativeImageUtils.registerClassForReflection( - access, "com.google.cloud.spanner.MockDatabaseAdminServiceImpl$MockBackup"); - } - } -} diff --git a/native-image-support/src/main/resources/META-INF/native-image/com.google.cloud/google-cloud-core/native-image.properties b/native-image-support/src/main/resources/META-INF/native-image/com.google.cloud/google-cloud-core/native-image.properties deleted file mode 100644 index 5ce9338cff..0000000000 --- a/native-image-support/src/main/resources/META-INF/native-image/com.google.cloud/google-cloud-core/native-image.properties +++ /dev/null @@ -1,2 +0,0 @@ -Args = --initialize-at-build-time=com.google.cloud.spanner.IntegrationTestEnv \ ---initialize-at-run-time=com.google.cloud.firestore.FirestoreImpl diff --git a/pom.xml b/pom.xml index 856ff7a574..b9192d22e9 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-core-parent pom - 2.6.1 + 2.7.0 Google Cloud Core Parent https://github.com/googleapis/java-core @@ -14,7 +14,7 @@ com.google.cloud google-cloud-shared-config - 1.3.2 + 1.4.0 @@ -151,17 +151,16 @@ UTF-8 github google-cloud-core-parent - 2.16.0 - 2.1.5 + 2.18.0 + 2.2.0 2.8.3 - 1.3.1 - 1.6.0 - 1.34.0 - 1.41.7 - 22.0.0.2 - 1.45.1 - 3.19.4 - 0.31.0 + 1.3.4 + 1.7.0 + 1.34.1 + 1.41.8 + 1.46.0 + 3.20.1 + 0.31.1 1.3.2 31.1-jre 4.13.2 @@ -170,7 +169,7 @@ 3.0.2 1.6.0 3.2 - 2.13.0 + 2.13.1 2.9.0 @@ -284,21 +283,6 @@ ${gson.version} - - - org.graalvm.nativeimage - svm - ${graalvm.version} - provided - - - - org.graalvm.sdk - graal-sdk - ${graalvm.version} - provided - - com.google.truth @@ -338,7 +322,6 @@ google-cloud-core-http google-cloud-core-grpc google-cloud-core-bom - native-image-support @@ -346,7 +329,7 @@ org.apache.maven.plugins maven-project-info-reports-plugin - 3.2.2 + 3.3.0 @@ -373,7 +356,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.3.2 + 3.4.0 html diff --git a/versions.txt b/versions.txt index 4ac408813c..6a17814c27 100644 --- a/versions.txt +++ b/versions.txt @@ -1,5 +1,4 @@ # Format: # module:released-version:current-version -google-cloud-core:2.6.1:2.6.1 -native-image-support:0.13.1:0.13.1 \ No newline at end of file +google-cloud-core:2.7.0:2.7.0