Skip to content

Commit

Permalink
Changes for Zipkin and Netty to run with latest Graal VM native-image
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Langer <[email protected]>
  • Loading branch information
tomas-langer committed Aug 19, 2019
1 parent 3dfb67e commit 8cb570f
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
#
# 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.
#

Args=--initialize-at-build-time=io.helidon.config.spi.Source,io.helidon.config.spi.OverrideSource,io.helidon.config.spi.PollingStrategy,io.helidon.config.internal.ConfigFileTypeDetector
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
# Graal native image supports additional configuration from this property file.
# Snake yaml uses reflection to instantiate a map.
#
Args=-H:ReflectionConfigurationResources=${.}/helidon-config-yaml-reflection-config.json
Args=-H:ReflectionConfigurationResources=${.}/helidon-config-yaml-reflection-config.json \
--initialize-at-build-time=io.helidon.config.yaml.internal.YamlFileTypeDetector
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package io.helidon.integrations.graal.nativeimage.extension;

import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.RecomputeFieldValue;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;
import io.netty.util.internal.logging.InternalLoggerFactory;
Expand All @@ -25,42 +23,10 @@
/**
* Substitutions for GraalVM native image generation.
*/
// supressing checkstyle issues, as this class cannot follow usual naming rules
// suppressing checkstyle issues, as this class cannot follow usual naming rules
@SuppressWarnings({"StaticVariableName", "VisibilityModifier"})
public final class NettySubstitutions {
@TargetClass(className = "io.netty.util.internal.PlatformDependent")
static final class PlatformDependentSvmExtension {
/**
* The class PlatformDependent caches the byte array base offset by reading the
* field from PlatformDependent0. The automatic recomputation of Substrate VM
* correctly recomputes the field in PlatformDependent0, but since the caching
* in PlatformDependent happens during image building, the non-recomputed value
* is cached.
*/
@Alias
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.ArrayBaseOffset, declClass = byte[].class)
private static long BYTE_ARRAY_BASE_OFFSET;
}

@TargetClass(className = "io.netty.util.internal.PlatformDependent0")
static final class PlatformDependent0SvmExtension {
@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FieldOffset, declClassName = "java.nio.Buffer", name =
"address")
private static long ADDRESS_FIELD_OFFSET;
}

@TargetClass(className = "io.netty.util.internal.CleanerJava6")
static final class CleanerJava6SvmExtension {
@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FieldOffset, declClassName = "java.nio.DirectByteBuffer",
name = "cleaner")
private static long CLEANER_FIELD_OFFSET;
}

@TargetClass(className = "io.netty.util.internal.shaded.org.jctools.util.UnsafeRefArrayAccess")
static final class UnsafeRefArrayAccessSvmExtension {
@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.ArrayIndexShift, declClass = Object[].class)
public static int REF_ELEMENT_SHIFT;
}
// latest Netty sources now contain Graal VM native-image substitutions, so we could remove them

@TargetClass(className = "io.netty.util.internal.logging.InternalLoggerFactory")
static final class InternalLoggerFactorySvmExtension {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
#
Args=-H:ReflectionConfigurationResources=${.}/helidon-native-image-extension-reflection-config.json \
--no-fallback \
--initialize-at-run-time=io.netty.util.internal.logging.Log4JLogger \
--initialize-at-build-time=io.helidon,io.netty,reactor.core,reactor.util,org.yaml.snakeyaml,org.reactivestreams,org.glassfish.json,org.eclipse.microprofile,io.opentracing,javax.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -267,8 +267,8 @@ public InboundClientDefinition build() {
public Builder config(Config config) {
keyId(config.get("key-id").asString().get());
config.get("principal-name").asString().ifPresent(this::principalName);
config.get("principal-type").as(SubjectType.class).ifPresent(this::subjectType);
config.get("public-key").as(KeyConfig.class).ifPresent(this::publicKeyConfig);
config.get("principal-type").asString().as(SubjectType::valueOf).ifPresent(this::subjectType);
config.get("public-key").as(KeyConfig::create).ifPresent(this::publicKeyConfig);
config.get("hmac.secret").asString().ifPresent(this::hmacSecret);
config.get("algorithm").asString().ifPresent(this::algorithm);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@
# Graal native image supports additional configuration from this property file.
# Zipkin requires http support over URL connection
#
Args=--enable-url-protocols=http
Args=--enable-url-protocols=http \
--initialize-at-build-time=io.helidon.tracing.zipkin,zipkin2

0 comments on commit 8cb570f

Please sign in to comment.