diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 426cf83e2e..f60d774937 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-java:latest - digest: sha256:b0b1c1c89570e229b1026372a2b8989ba31495007055b8d30178b7648503eefa + digest: sha256:fc52b202aa298a50a12c64efd04fea3884d867947effe2fa85382a246c09e813 +# created: 2022-04-06T16:30:03.627422514Z diff --git a/.github/auto-label.yaml b/.github/auto-label.yaml new file mode 100644 index 0000000000..4caef688b7 --- /dev/null +++ b/.github/auto-label.yaml @@ -0,0 +1,15 @@ +# Copyright 2021 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 +# +# 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. +requestsize: + enabled: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 7694bb9efd..6d80f4d69e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,38 @@ # Changelog +## [2.6.0](https://github.com/googleapis/java-core/compare/v2.5.11...v2.6.0) (2022-04-14) + + +### Features + +* **java:** remove GoogleJsonClentFeature and OpenCensusFeature after relocation ([#793](https://github.com/googleapis/java-core/issues/793)) ([2880112](https://github.com/googleapis/java-core/commit/28801121a50583118286419ac91332a201285c4c)) +* **java:** remove Netty Native Image configuration after relocation to gax ([#771](https://github.com/googleapis/java-core/issues/771)) ([9ba04f9](https://github.com/googleapis/java-core/commit/9ba04f9f135e1ff7344bb45eeb5796154616ef20)) +* **java:** remove protobuf Native Image configuration ([#784](https://github.com/googleapis/java-core/issues/784)) ([0bc8549](https://github.com/googleapis/java-core/commit/0bc8549d3364ac169f21cc00c00497cd59998106)) +* remove native-image.properties settings after relocation ([#794](https://github.com/googleapis/java-core/issues/794)) ([e24bfdd](https://github.com/googleapis/java-core/commit/e24bfddbb9f588fbf69cdc0022cdf67f2c628278)) +* remove resource-config after relocation ([#795](https://github.com/googleapis/java-core/issues/795)) ([87e2973](https://github.com/googleapis/java-core/commit/87e29733c3714b39000e5fa3d232c35ce69955a2)) +* remove substitutions after relocation to gax ([#789](https://github.com/googleapis/java-core/issues/789)) ([29291e9](https://github.com/googleapis/java-core/commit/29291e9f50e4500ef5d5c1fe30098d025b216f9a)) + + +### Bug Fixes + +* **java:** register test class for reflection to fix native image test ([#766](https://github.com/googleapis/java-core/issues/766)) ([6fe52c3](https://github.com/googleapis/java-core/commit/6fe52c3424546cad7b8158668d3f8a655b56af41)) + + +### Dependencies + +* revert protobuf to 3.19 and common-protos 2.8.3 ([#798](https://github.com/googleapis/java-core/issues/798)) ([0f36a84](https://github.com/googleapis/java-core/commit/0f36a848a03c50d5d0187241bccd66fdb0cea862)) +* update dependency com.google.api-client:google-api-client-bom to v1.34.0 ([#800](https://github.com/googleapis/java-core/issues/800)) ([8430aee](https://github.com/googleapis/java-core/commit/8430aee231100ef13296f22f09265589b2aa0252)) +* update dependency com.google.api:gax-bom to v2.16.0 ([#785](https://github.com/googleapis/java-core/issues/785)) ([fd435b0](https://github.com/googleapis/java-core/commit/fd435b00f01fac1dc96b5f401b403d67809fa1eb)) +* update dependency com.google.api.grpc:proto-google-common-protos to v2.8.1 ([#792](https://github.com/googleapis/java-core/issues/792)) ([4d201ac](https://github.com/googleapis/java-core/commit/4d201ac5dc694c9e4a4f06c5580a0c707ea68b87)) +* update dependency com.google.api.grpc:proto-google-common-protos to v2.8.2 ([#796](https://github.com/googleapis/java-core/issues/796)) ([dc28a0f](https://github.com/googleapis/java-core/commit/dc28a0f2d58bcf4eb3c9b9f129ce8d88470e94e6)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.3.0 ([#783](https://github.com/googleapis/java-core/issues/783)) ([4ed5ba4](https://github.com/googleapis/java-core/commit/4ed5ba4d096cb19f60186cbcfc789f5b058b07f8)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.3.1 ([#799](https://github.com/googleapis/java-core/issues/799)) ([fce5315](https://github.com/googleapis/java-core/commit/fce531519184225e103a8faad54e81ae9232210a)) +* update dependency com.google.errorprone:error_prone_annotations to v2.12.1 ([#788](https://github.com/googleapis/java-core/issues/788)) ([4e71f68](https://github.com/googleapis/java-core/commit/4e71f680142bf8cffaa519dcb0fd2916458674e2)) +* update dependency com.google.http-client:google-http-client-bom to v1.41.6 ([#791](https://github.com/googleapis/java-core/issues/791)) ([fe006c6](https://github.com/googleapis/java-core/commit/fe006c60e6cbaff8127a9f6f6792c6a6ce9ff26b)) +* update dependency com.google.http-client:google-http-client-bom to v1.41.7 ([#797](https://github.com/googleapis/java-core/issues/797)) ([570f8d5](https://github.com/googleapis/java-core/commit/570f8d5870044d1f3026b4aec49a6800d904f1be)) +* update dependency com.google.protobuf:protobuf-bom to v3.20.0 ([#787](https://github.com/googleapis/java-core/issues/787)) ([19202bc](https://github.com/googleapis/java-core/commit/19202bcb76e28977e0f2c9b02c75c83644bfb438)) +* update dependency io.grpc:grpc-bom to v1.45.1 ([#780](https://github.com/googleapis/java-core/issues/780)) ([6e3bf35](https://github.com/googleapis/java-core/commit/6e3bf35c501028ac293a401f55c14f1d97fa3953)) + ### [2.5.11](https://github.com/googleapis/java-core/compare/v2.5.10...v2.5.11) (2022-03-28) diff --git a/google-cloud-core-bom/pom.xml b/google-cloud-core-bom/pom.xml index 597dfc494a..54c29744cc 100644 --- a/google-cloud-core-bom/pom.xml +++ b/google-cloud-core-bom/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-core-bom - 2.5.11 + 2.6.0 pom com.google.cloud @@ -63,22 +63,22 @@ com.google.cloud google-cloud-core - 2.5.11 + 2.6.0 com.google.cloud google-cloud-core-grpc - 2.5.11 + 2.6.0 com.google.cloud google-cloud-core-http - 2.5.11 + 2.6.0 com.google.cloud native-image-support - 0.12.11 + 0.13.0 diff --git a/google-cloud-core-grpc/pom.xml b/google-cloud-core-grpc/pom.xml index 92eadb7115..12b95a270c 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.5.11 + 2.6.0 jar Google Cloud Core gRPC https://github.com/googleapis/java-core @@ -13,7 +13,7 @@ com.google.cloud google-cloud-core-parent - 2.5.11 + 2.6.0 google-cloud-core-grpc diff --git a/google-cloud-core-http/pom.xml b/google-cloud-core-http/pom.xml index 07d8850b8e..60488d06c5 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.5.11 + 2.6.0 jar Google Cloud Core HTTP https://github.com/googleapis/java-core @@ -13,7 +13,7 @@ com.google.cloud google-cloud-core-parent - 2.5.11 + 2.6.0 google-cloud-core-http diff --git a/google-cloud-core/pom.xml b/google-cloud-core/pom.xml index a23267a7c2..7b94f9b876 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.5.11 + 2.6.0 jar Google Cloud Core https://github.com/googleapis/java-core @@ -13,7 +13,7 @@ com.google.cloud google-cloud-core-parent - 2.5.11 + 2.6.0 google-cloud-core diff --git a/native-image-support/pom.xml b/native-image-support/pom.xml index 744594fe2f..17936e2141 100644 --- a/native-image-support/pom.xml +++ b/native-image-support/pom.xml @@ -7,13 +7,13 @@ Google Cloud Native Image Support com.google.cloud native-image-support - 0.12.11 + 0.13.0 jar google-cloud-core-parent com.google.cloud - 2.5.11 + 2.6.0 @@ -21,16 +21,6 @@ - - com.google.guava - guava - - - - io.grpc - grpc-netty-shaded - provided - org.graalvm.nativeimage diff --git a/native-image-support/src/main/java/com/google/cloud/nativeimage/features/GoogleJsonClientFeature.java b/native-image-support/src/main/java/com/google/cloud/nativeimage/features/GoogleJsonClientFeature.java deleted file mode 100644 index 8cc3107f4e..0000000000 --- a/native-image-support/src/main/java/com/google/cloud/nativeimage/features/GoogleJsonClientFeature.java +++ /dev/null @@ -1,99 +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 static com.google.cloud.nativeimage.features.NativeImageUtils.registerClassForReflection; - -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; - -/** Configures Native Image settings for the Google JSON Client. */ -@AutomaticFeature -final class GoogleJsonClientFeature implements Feature { - - private static final String GOOGLE_API_CLIENT_CLASS = - "com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient"; - - private static final String GOOGLE_API_CLIENT_REQUEST_CLASS = - "com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest"; - - private static final String GENERIC_JSON_CLASS = "com.google.api.client.json.GenericJson"; - - @Override - public void beforeAnalysis(BeforeAnalysisAccess access) { - loadApiClient(access); - loadHttpClient(access); - loadMiscClasses(access); - } - - private void loadApiClient(BeforeAnalysisAccess access) { - // For com.google.api-client:google-api-client - Class googleApiClientClass = access.findClassByName(GOOGLE_API_CLIENT_CLASS); - - if (googleApiClientClass != null) { - // All reachable instances of the AbstractGoogleJsonClient must be registered. - access.registerSubtypeReachabilityHandler( - (duringAccess, subtype) -> registerClassForReflection(access, subtype.getName()), - googleApiClientClass); - - // All reachable instances of the AbstractGoogleJsonClientRequest must be registered. - access.registerSubtypeReachabilityHandler( - (duringAccess, subtype) -> registerClassForReflection(access, subtype.getName()), - access.findClassByName(GOOGLE_API_CLIENT_REQUEST_CLASS)); - - // Resources - ResourcesRegistry resourcesRegistry = ImageSingletons.lookup(ResourcesRegistry.class); - resourcesRegistry.addResources( - "\\Qcom/google/api/client/googleapis/google-api-client.properties\\E"); - resourcesRegistry.addResources("\\Qcom/google/api/client/googleapis/google.p12\\E"); - resourcesRegistry.addResources( - "\\Qcom/google/api/client/http/google-http-client.properties\\E"); - } - } - - private void loadHttpClient(BeforeAnalysisAccess access) { - // For com.google.http-client:google-http-client - Class genericJsonClass = access.findClassByName(GENERIC_JSON_CLASS); - - if (genericJsonClass != null) { - // All reachable instances of GenericJson must be registered. - access.registerSubtypeReachabilityHandler( - (duringAccess, subtype) -> registerClassForReflection(access, subtype.getName()), - genericJsonClass); - - registerClassForReflection(access, "com.google.api.client.util.GenericData"); - registerClassForReflection(access, "com.google.api.client.json.webtoken.JsonWebToken"); - registerClassForReflection(access, "com.google.api.client.json.webtoken.JsonWebToken$Header"); - registerClassForReflection( - access, "com.google.api.client.json.webtoken.JsonWebToken$Payload"); - registerClassForReflection( - access, "com.google.api.client.json.webtoken.JsonWebSignature$Header"); - registerClassForReflection(access, "com.google.api.client.json.webtoken.JsonWebSignature"); - registerClassForReflection(access, "com.google.api.client.http.UrlEncodedContent"); - registerClassForReflection(access, "com.google.api.client.http.GenericUrl"); - registerClassForReflection(access, "com.google.api.client.http.HttpRequest"); - registerClassForReflection(access, "com.google.api.client.http.HttpHeaders"); - } - } - - private void loadMiscClasses(BeforeAnalysisAccess access) { - registerClassForReflection(access, "com.google.common.util.concurrent.AbstractFuture"); - registerClassForReflection(access, "com.google.common.util.concurrent.AbstractFuture$Waiter"); - } -} diff --git a/native-image-support/src/main/java/com/google/cloud/nativeimage/features/GrpcNettyFeature.java b/native-image-support/src/main/java/com/google/cloud/nativeimage/features/GrpcNettyFeature.java deleted file mode 100644 index 754f9005e2..0000000000 --- a/native-image-support/src/main/java/com/google/cloud/nativeimage/features/GrpcNettyFeature.java +++ /dev/null @@ -1,122 +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 static com.google.cloud.nativeimage.features.NativeImageUtils.registerClassForReflection; -import static com.google.cloud.nativeimage.features.NativeImageUtils.registerClassHierarchyForReflection; -import static com.google.cloud.nativeimage.features.NativeImageUtils.registerForReflectiveInstantiation; -import static com.google.cloud.nativeimage.features.NativeImageUtils.registerForUnsafeFieldAccess; - -import com.oracle.svm.core.annotate.AutomaticFeature; -import org.graalvm.nativeimage.hosted.Feature; - -/** Configures Native Image settings for the grpc-netty-shaded dependency. */ -@AutomaticFeature -final class GrpcNettyFeature implements Feature { - - private static final String GRPC_NETTY_SHADED_CLASS = - "io.grpc.netty.shaded.io.grpc.netty.NettyServer"; - - private static final String GOOGLE_AUTH_CLASS = - "com.google.auth.oauth2.ServiceAccountCredentials"; - - @Override - public void beforeAnalysis(BeforeAnalysisAccess access) { - loadGoogleAuthClasses(access); - loadGrpcNettyClasses(access); - loadMiscClasses(access); - } - - private static void loadGoogleAuthClasses(BeforeAnalysisAccess access) { - // For com.google.auth:google-auth-library-oauth2-http - Class authClass = access.findClassByName(GOOGLE_AUTH_CLASS); - if (authClass != null) { - registerClassHierarchyForReflection( - access, "com.google.auth.oauth2.ServiceAccountCredentials"); - registerClassHierarchyForReflection( - access, "com.google.auth.oauth2.ServiceAccountJwtAccessCredentials"); - } - } - - private static void loadGrpcNettyClasses(BeforeAnalysisAccess access) { - // For io.grpc:grpc-netty-shaded - Class nettyShadedClass = access.findClassByName(GRPC_NETTY_SHADED_CLASS); - if (nettyShadedClass != null) { - // Misc. classes used by grpc-netty-shaded - registerForReflectiveInstantiation( - access, "io.grpc.netty.shaded.io.netty.channel.socket.nio.NioSocketChannel"); - registerClassForReflection( - access, "io.grpc.netty.shaded.io.netty.util.internal.NativeLibraryUtil"); - registerClassForReflection(access, "io.grpc.netty.shaded.io.netty.util.ReferenceCountUtil"); - registerClassForReflection( - access, "io.grpc.netty.shaded.io.netty.buffer.AbstractByteBufAllocator"); - - // Epoll Libraries - registerClassForReflection(access, "io.grpc.netty.shaded.io.netty.channel.epoll.Epoll"); - registerClassForReflection( - access, "io.grpc.netty.shaded.io.netty.channel.epoll.EpollChannelOption"); - registerClassForReflection( - access, "io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoopGroup"); - registerForReflectiveInstantiation( - access, "io.grpc.netty.shaded.io.netty.channel.epoll.EpollServerSocketChannel"); - registerForReflectiveInstantiation( - access, "io.grpc.netty.shaded.io.netty.channel.epoll.EpollSocketChannel"); - - // Unsafe field accesses - registerForUnsafeFieldAccess( - access, - "io.grpc.netty.shaded.io.netty.util.internal.shaded." - + "org.jctools.queues.MpscArrayQueueProducerIndexField", - "producerIndex"); - registerForUnsafeFieldAccess( - access, - "io.grpc.netty.shaded.io.netty.util.internal.shaded." - + "org.jctools.queues.MpscArrayQueueProducerLimitField", - "producerLimit"); - registerForUnsafeFieldAccess( - access, - "io.grpc.netty.shaded.io.netty.util.internal.shaded." - + "org.jctools.queues.MpscArrayQueueConsumerIndexField", - "consumerIndex"); - registerForUnsafeFieldAccess( - access, - "io.grpc.netty.shaded.io.netty.util.internal.shaded." - + "org.jctools.queues.BaseMpscLinkedArrayQueueProducerFields", - "producerIndex"); - registerForUnsafeFieldAccess( - access, - "io.grpc.netty.shaded.io.netty.util.internal.shaded." - + "org.jctools.queues.BaseMpscLinkedArrayQueueColdProducerFields", - "producerLimit"); - registerForUnsafeFieldAccess( - access, - "io.grpc.netty.shaded.io.netty.util.internal.shaded." - + "org.jctools.queues.BaseMpscLinkedArrayQueueConsumerFields", - "consumerIndex"); - } - } - - /** Miscellaneous classes that need to be registered coming from various JARs. */ - private static void loadMiscClasses(BeforeAnalysisAccess access) { - registerClassHierarchyForReflection(access, "com.google.protobuf.DescriptorProtos"); - registerClassForReflection(access, "com.google.api.FieldBehavior"); - - registerForUnsafeFieldAccess(access, "javax.net.ssl.SSLContext", "contextSpi"); - registerClassForReflection(access, "java.lang.management.ManagementFactory"); - registerClassForReflection(access, "java.lang.management.RuntimeMXBean"); - } -} diff --git a/native-image-support/src/main/java/com/google/cloud/nativeimage/features/ProtobufMessageFeature.java b/native-image-support/src/main/java/com/google/cloud/nativeimage/features/ProtobufMessageFeature.java deleted file mode 100644 index 40251e85e4..0000000000 --- a/native-image-support/src/main/java/com/google/cloud/nativeimage/features/ProtobufMessageFeature.java +++ /dev/null @@ -1,105 +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.lang.reflect.Method; -import java.util.Arrays; -import java.util.List; -import org.graalvm.nativeimage.hosted.Feature; -import org.graalvm.nativeimage.hosted.RuntimeReflection; - -/** - * A optional feature which registers reflective usages of the GRPC Protobuf libraries. - * - *

This feature is only needed if you need to access proto objects reflectively (such as - * printing/logging proto objects). - * - *

To add this feature, add "--feature - * com.google.cloud.nativeimage.features.ProtobufMessageFeature" to your GraalVM configuration. - */ -final class ProtobufMessageFeature implements Feature { - - // Proto classes to check on the classpath. - private static final String PROTO_MESSAGE_CLASS = "com.google.protobuf.GeneratedMessageV3"; - private static final String PROTO_ENUM_CLASS = "com.google.protobuf.ProtocolMessageEnum"; - private static final String ENUM_VAL_DESCRIPTOR_CLASS = - "com.google.protobuf.Descriptors$EnumValueDescriptor"; - - // Prefixes of methods accessed reflectively by - // com.google.protobuf.GeneratedMessageV3$ReflectionInvoker - private static final List METHOD_ACCESSOR_PREFIXES = - Arrays.asList("get", "set", "has", "add", "clear", "newBuilder"); - - @Override - public void beforeAnalysis(BeforeAnalysisAccess access) { - Class protoMessageClass = access.findClassByName(PROTO_MESSAGE_CLASS); - if (protoMessageClass != null) { - Method internalAccessorMethod = - NativeImageUtils.getMethodOrFail(protoMessageClass, "internalGetFieldAccessorTable"); - - // Finds every class whose `internalGetFieldAccessorTable()` is reached and registers it. - // `internalGetFieldAccessorTable()` is used downstream to access the class reflectively. - access.registerMethodOverrideReachabilityHandler( - (duringAccess, method) -> { - registerFieldAccessors(method.getDeclaringClass()); - registerFieldAccessors(getBuilderClass(method.getDeclaringClass())); - }, - internalAccessorMethod); - } - - Class protoEnumClass = access.findClassByName(PROTO_ENUM_CLASS); - if (protoEnumClass != null) { - // Finds every reachable proto enum class and registers specific methods for reflection. - access.registerSubtypeReachabilityHandler( - (duringAccess, subtypeClass) -> { - if (!PROTO_ENUM_CLASS.equals(subtypeClass.getName())) { - Method method = - NativeImageUtils.getMethodOrFail( - subtypeClass, - "valueOf", - duringAccess.findClassByName(ENUM_VAL_DESCRIPTOR_CLASS)); - RuntimeReflection.register(method); - - method = NativeImageUtils.getMethodOrFail(subtypeClass, "getValueDescriptor"); - RuntimeReflection.register(method); - } - }, - protoEnumClass); - } - } - - /** Given a proto class, registers the public accessor methods for the provided proto class. */ - private static void registerFieldAccessors(Class protoClass) { - for (Method method : protoClass.getMethods()) { - boolean hasAccessorPrefix = - METHOD_ACCESSOR_PREFIXES.stream().anyMatch(prefix -> method.getName().startsWith(prefix)); - if (hasAccessorPrefix) { - RuntimeReflection.register(method); - } - } - } - - /** Given a proto class, returns the Builder nested class. */ - private static Class getBuilderClass(Class protoClass) { - for (Class clazz : protoClass.getClasses()) { - if (clazz.getName().endsWith("Builder")) { - return clazz; - } - } - return null; - } -} diff --git a/native-image-support/src/main/java/com/google/cloud/nativeimage/features/clients/OpenCensusFeature.java b/native-image-support/src/main/java/com/google/cloud/nativeimage/features/clients/OpenCensusFeature.java deleted file mode 100644 index e718f28567..0000000000 --- a/native-image-support/src/main/java/com/google/cloud/nativeimage/features/clients/OpenCensusFeature.java +++ /dev/null @@ -1,42 +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.registerForReflectiveInstantiation; - -import com.oracle.svm.core.annotate.AutomaticFeature; -import org.graalvm.nativeimage.hosted.Feature; - -/** Registers reflection usage in OpenCensus libraries. */ -@AutomaticFeature -final class OpenCensusFeature implements Feature { - - private static final String TAGS_COMPONENT_CLASS = "io.opencensus.impl.tags.TagsComponentImpl"; - private static final String STATS_COMPONENT_CLASS = "io.opencensus.impl.stats.StatsComponentImpl"; - - @Override - public void beforeAnalysis(BeforeAnalysisAccess access) { - if (access.findClassByName(STATS_COMPONENT_CLASS) != null) { - registerForReflectiveInstantiation(access, STATS_COMPONENT_CLASS); - } - if (access.findClassByName(TAGS_COMPONENT_CLASS) != null) { - registerForReflectiveInstantiation(access, "io.opencensus.impl.metrics.MetricsComponentImpl"); - registerForReflectiveInstantiation(access, "io.opencensus.impl.tags.TagsComponentImpl"); - registerForReflectiveInstantiation(access, "io.opencensus.impl.trace.TraceComponentImpl"); - } - } -} 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 index 7c9fca1421..956f368dac 100644 --- 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 @@ -29,6 +29,7 @@ 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 = @@ -50,10 +51,7 @@ final class SpannerFeature implements Feature { @Override public void beforeAnalysis(BeforeAnalysisAccess access) { - Class spannerTestClass = access.findClassByName(SPANNER_TEST_CLASS); - if (spannerTestClass != null) { - NativeImageUtils.registerConstructorsForReflection(access, SPANNER_TEST_CLASS); - } + registerSpannerTestClasses(access); if (access.findClassByName(CLIENT_SIDE_IMPL_CLASS) != null) { NativeImageUtils.registerClassHierarchyForReflection(access, CLIENT_SIDE_IMPL_CLASS); } @@ -103,4 +101,16 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { "\\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/java/com/google/cloud/nativeimage/features/substitutions/ApiClientVersionSubstitutions.java b/native-image-support/src/main/java/com/google/cloud/nativeimage/features/substitutions/ApiClientVersionSubstitutions.java deleted file mode 100644 index c170c2ea7a..0000000000 --- a/native-image-support/src/main/java/com/google/cloud/nativeimage/features/substitutions/ApiClientVersionSubstitutions.java +++ /dev/null @@ -1,64 +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.substitutions; - -import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; -import java.util.function.BooleanSupplier; - -/** Substitution for setting Java version correctly in the Google Java Http Client. */ -@TargetClass( - className = - "com.google.api.client.googleapis.services.AbstractGoogleClientRequest$ApiClientVersion", - onlyWith = ApiClientVersionSubstitutions.OnlyIfInClassPath.class) -final class ApiClientVersionSubstitutions { - - @Alias private String versionString; - - @Substitute - public String toString() { - String[] tokens = versionString.split(" "); - - if (tokens.length > 0 && tokens[0].startsWith("gl-java")) { - tokens[0] += "-graalvm"; - return String.join(" ", tokens); - } else { - return versionString; - } - } - - private ApiClientVersionSubstitutions() {} - - static class OnlyIfInClassPath implements BooleanSupplier { - - @Override - public boolean getAsBoolean() { - try { - // Note: Set initialize = false to avoid initializing the class when looking it up. - Class.forName( - "com.google.api.client.googleapis.services." - + "AbstractGoogleClientRequest$ApiClientVersion", - false, - Thread.currentThread().getContextClassLoader()); - return true; - } catch (ClassNotFoundException e) { - return false; - } - } - } -} diff --git a/native-image-support/src/main/java/com/google/cloud/nativeimage/features/substitutions/GaxPropertiesSubstitutions.java b/native-image-support/src/main/java/com/google/cloud/nativeimage/features/substitutions/GaxPropertiesSubstitutions.java deleted file mode 100644 index 54245a8ee8..0000000000 --- a/native-image-support/src/main/java/com/google/cloud/nativeimage/features/substitutions/GaxPropertiesSubstitutions.java +++ /dev/null @@ -1,56 +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.substitutions; - -import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.RecomputeFieldValue; -import com.oracle.svm.core.annotate.RecomputeFieldValue.Kind; -import com.oracle.svm.core.annotate.TargetClass; -import java.util.function.BooleanSupplier; - -/** - * This file contains the GaxProperties substitution to correctly set the Java language string in - * API call headers for Native Image users. - */ -@TargetClass( - className = "com.google.api.gax.core.GaxProperties", - onlyWith = GaxPropertiesSubstitutions.OnlyIfInClassPath.class) -final class GaxPropertiesSubstitutions { - - @Alias - @RecomputeFieldValue(kind = Kind.FromAlias) - private static String JAVA_VERSION = System.getProperty("java.version") + "-graalvm"; - - private GaxPropertiesSubstitutions() {} - - static class OnlyIfInClassPath implements BooleanSupplier { - - @Override - public boolean getAsBoolean() { - try { - // Note: Set initialize = false to avoid initializing the class when looking it up. - Class.forName( - "com.google.api.gax.core.GaxProperties", - false, - Thread.currentThread().getContextClassLoader()); - return true; - } catch (ClassNotFoundException e) { - return false; - } - } - } -} diff --git a/native-image-support/src/main/java/com/google/cloud/nativeimage/features/substitutions/NettyInternalLoggerFactorySubstitutions.java b/native-image-support/src/main/java/com/google/cloud/nativeimage/features/substitutions/NettyInternalLoggerFactorySubstitutions.java deleted file mode 100644 index 7fcea16318..0000000000 --- a/native-image-support/src/main/java/com/google/cloud/nativeimage/features/substitutions/NettyInternalLoggerFactorySubstitutions.java +++ /dev/null @@ -1,55 +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.substitutions; - -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; -import io.grpc.netty.shaded.io.netty.util.internal.logging.InternalLoggerFactory; -import io.grpc.netty.shaded.io.netty.util.internal.logging.JdkLoggerFactory; -import java.util.function.BooleanSupplier; - -/** - * Substitutions for {@link InternalLoggerFactory} which are needed to avoid dynamic loading of - * logging library. - */ -@TargetClass( - className = "io.grpc.netty.shaded.io.netty.util.internal.logging.InternalLoggerFactory", - onlyWith = NettyInternalLoggerFactorySubstitutions.OnlyIfInClassPath.class) -final class NettyInternalLoggerFactorySubstitutions { - - @Substitute - private static InternalLoggerFactory newDefaultFactory(String name) { - return JdkLoggerFactory.INSTANCE; - } - - static class OnlyIfInClassPath implements BooleanSupplier { - - @Override - public boolean getAsBoolean() { - try { - // Note: Set initialize = false to avoid initializing the class when looking it up. - Class.forName( - "io.grpc.netty.shaded.io.netty.util.internal.logging.InternalLoggerFactory", - false, - Thread.currentThread().getContextClassLoader()); - return true; - } catch (ClassNotFoundException e) { - return false; - } - } - } -} 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 index 2228a1f094..5ce9338cff 100644 --- 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 @@ -1,18 +1,2 @@ -Args = --allow-incomplete-classpath \ ---enable-url-protocols=https,http \ ---initialize-at-build-time=org.conscrypt,\ - org.slf4j.LoggerFactory,\ - org.junit.platform.engine.TestTag,\ - com.google.cloud.spanner.IntegrationTestEnv \ ---initialize-at-run-time=io.grpc.netty.shaded.io.netty.handler.ssl.OpenSsl,\ - io.grpc.netty.shaded.io.netty.internal.tcnative.SSL,\ - io.grpc.netty.shaded.io.netty.internal.tcnative.CertificateVerifier,\ - io.grpc.netty.shaded.io.netty.internal.tcnative.SSLPrivateKeyMethod,\ - io.grpc.netty.shaded.io.netty.internal.tcnative.AsyncSSLPrivateKeyMethod,\ - io.grpc.netty.shaded.io.grpc.netty,\ - io.grpc.netty.shaded.io.netty.channel.epoll,\ - io.grpc.netty.shaded.io.netty.channel.unix,\ - io.grpc.netty.shaded.io.netty.handler.ssl,\ - io.grpc.internal.RetriableStream,\ - com.google.api.client.googleapis.services.AbstractGoogleClientRequest$ApiClientVersion,\ - com.google.cloud.firestore.FirestoreImpl +Args = --initialize-at-build-time=com.google.cloud.spanner.IntegrationTestEnv \ +--initialize-at-run-time=com.google.cloud.firestore.FirestoreImpl diff --git a/native-image-support/src/main/resources/META-INF/native-image/com.google.cloud/google-cloud-core/resource-config.json b/native-image-support/src/main/resources/META-INF/native-image/com.google.cloud/google-cloud-core/resource-config.json deleted file mode 100644 index 3afe5ffebc..0000000000 --- a/native-image-support/src/main/resources/META-INF/native-image/com.google.cloud/google-cloud-core/resource-config.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "resources":[ - {"pattern":"\\QMETA-INF/native/libio_grpc_netty_shaded_netty_tcnative_linux_x86_64.so\\E"}, - {"pattern":"\\QMETA-INF/native/libio_grpc_netty_shaded_netty_transport_native_epoll_x86_64.so\\E"}, - {"pattern":"\\QMETA-INF/services/io.grpc.LoadBalancerProvider\\E"}, - {"pattern":"\\QMETA-INF/services/io.grpc.ManagedChannelProvider\\E"}, - {"pattern":"\\QMETA-INF/services/io.grpc.NameResolverProvider\\E"}, - {"pattern":"\\QMETA-INF/services/jdk.vm.ci.services.JVMCIServiceLocator\\E"}, - {"pattern":"\\Qdependencies.properties\\E"}, - {"pattern":"\\Qgoogle-http-client.properties\\E"} - ], - "bundles":[] -} diff --git a/pom.xml b/pom.xml index b25f8c179b..a1d5a723a0 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-core-parent pom - 2.5.11 + 2.6.0 Google Cloud Core Parent https://github.com/googleapis/java-core @@ -151,15 +151,15 @@ UTF-8 github google-cloud-core-parent - 2.13.0 + 2.16.0 2.1.5 - 2.8.0 - 1.2.10 + 2.8.3 + 1.3.1 1.6.0 - 1.33.4 - 1.41.5 + 1.34.0 + 1.41.7 22.0.0.2 - 1.45.0 + 1.45.1 3.19.4 0.31.0 1.3.2 @@ -170,7 +170,7 @@ 3.0.2 1.6.0 3.2 - 2.11.0 + 2.12.1 2.9.0 diff --git a/versions.txt b/versions.txt index 906d83d5ea..e156d8679a 100644 --- a/versions.txt +++ b/versions.txt @@ -1,5 +1,5 @@ # Format: # module:released-version:current-version -google-cloud-core:2.5.11:2.5.11 -native-image-support:0.12.11:0.12.11 \ No newline at end of file +google-cloud-core:2.6.0:2.6.0 +native-image-support:0.13.0:0.13.0 \ No newline at end of file