Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
loicottet committed Mar 12, 2022
1 parent 1872df9 commit 830e38c
Show file tree
Hide file tree
Showing 25 changed files with 967 additions and 753 deletions.
10 changes: 5 additions & 5 deletions docs/reference-manual/native-image/BuildOutput.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ To reduce overhead, please ensure that the classpath only contains entries that
#### <a name="glossary-reflection-registrations"></a>Reflection Registrations
The number of classes, fields, and methods that are registered for reflection.
Large numbers can cause significant reflection overheads, slow down the build process, and increase the size of the native image (see [method metadata](#glossary-method-metadata)).
Large numbers can cause significant reflection overheads, slow down the build process, and increase the size of the native image (see [reflection metadata](#glossary-reflection-metadata)).
#### <a name="glossary-jni-access-registrations"></a>JNI Access Registrations
The number of classes, fields, and methods that are registered for [JNI][doc_jni] access.
Expand Down Expand Up @@ -136,16 +136,16 @@ Therefore, reducing the number of [reachable methods](#glossary-reachability) al
The image heap contains reachable objects such as static application data, metadata, and `byte[]` for different purposes.
##### <a name="glossary-general-heap-data"></a>General Heap Data Stored in `byte[]`
The total size of all `byte[]` objects that are neither used for `java.lang.String`, nor [code metadata](#glossary-code-metadata), nor [method metadata](#glossary-method-metadata), nor [graph encodings](#glossary-graph-encodings).
The total size of all `byte[]` objects that are neither used for `java.lang.String`, nor [code metadata](#glossary-code-metadata), nor [reflection metadata](#glossary-reflection-metadata), nor [graph encodings](#glossary-graph-encodings).
Therefore, this can also include `byte[]` objects from application code.
##### <a name="glossary-code-metadata"></a>Code Metadata Stored in `byte[]`
The total size of all `byte[]` objects used for metadata for the [code area](#glossary-code-area).
Therefore, reducing the number of [reachable methods](#glossary-reachability) also reduces the size of this metadata.
##### <a name="glossary-method-metadata"></a>Method Metadata Stored in `byte[]`
The total size of all `byte[]` objects used for method metadata, a type of reflection metadata.
To reduce the amount of method metadata, reduce the number of [classes registered for reflection](#glossary-reflection-classes).
##### <a name="glossary-reflection-metadata"></a>Reflection Metadata Stored in `byte[]`
The total size of all `byte[]` objects used for reflection metadata, including class, field, method and constructor data.
To reduce the amount of reflection metadata, reduce the number of [elements registered for reflection](#glossary-reflection-registrations).
##### <a name="glossary-graph-encodings"></a>Graph Encodings Stored in `byte[]`
The total size of all `byte[]` objects used for graph encodings.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
Expand Down Expand Up @@ -47,6 +47,8 @@
import java.util.Collections;
import java.util.List;

import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;
import org.graalvm.nativeimage.c.function.CLibrary;

/**
Expand All @@ -58,6 +60,7 @@
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@Platforms(Platform.HOSTED_ONLY.class)

This comment has been minimized.

Copy link
@huahaiy

huahaiy Dec 15, 2022

@loicottet

Why is that? CContext would need to be pulled into native image if C interop is needed to be done in there. This breaks a lot of code.

public @interface CContext {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ public interface RuntimeReflectionSupport extends ReflectionRegistry {

Object[] getRecordComponents(Class<?> type);

void registerHeapDynamicHub(Object hub);

Set<?> getHeapDynamicHubs();

void registerHeapReflectionObject(AccessibleObject object);

Set<AccessibleObject> getHeapReflectionObjects();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ protected final void scanField(AnalysisField field, JavaConstant receiver, ScanR
throw AnalysisError.shouldNotReachHere("Could not find field " + field.format("%H.%n") +
(receiver == null ? "" : " on " + constantType(bb, receiver).toJavaName()) +
System.lineSeparator() + backtrace);
} else if (fieldValue.getJavaKind() == JavaKind.Illegal) {
/* The value is not available yet */
return;
}

if (fieldValue.getJavaKind() == JavaKind.Object && bb.getHostVM().isRelocatedPointer(constantAsObject(bb, fieldValue))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,11 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, String ol
}
};

@SuppressWarnings("unused")//
@APIOption(name = "configure-reflection-metadata")//
@Option(help = "Enable runtime instantiation of reflection objects for non-invoked methods.", type = OptionType.Expert, deprecated = true)//
public static final HostedOptionKey<Boolean> ConfigureReflectionMetadata = new HostedOptionKey<>(true);

@Option(help = "Include a list of methods included in the image for runtime inspection.", type = OptionType.Expert)//
public static final HostedOptionKey<Boolean> IncludeMethodData = new HostedOptionKey<>(true);

Expand Down
Loading

0 comments on commit 830e38c

Please sign in to comment.