|
| 1 | +/* |
| 2 | + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | + * |
| 5 | + * The Universal Permissive License (UPL), Version 1.0 |
| 6 | + * |
| 7 | + * Subject to the condition set forth below, permission is hereby granted to any |
| 8 | + * person obtaining a copy of this software, associated documentation and/or |
| 9 | + * data (collectively the "Software"), free of charge and under any and all |
| 10 | + * copyright rights in the Software, and any and all patent rights owned or |
| 11 | + * freely licensable by each licensor hereunder covering either (i) the |
| 12 | + * unmodified Software as contributed to or provided by such licensor, or (ii) |
| 13 | + * the Larger Works (as defined below), to deal in both |
| 14 | + * |
| 15 | + * (a) the Software, and |
| 16 | + * |
| 17 | + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if |
| 18 | + * one is included with the Software each a "Larger Work" to which the Software |
| 19 | + * is contributed by such licensors), |
| 20 | + * |
| 21 | + * without restriction, including without limitation the rights to copy, create |
| 22 | + * derivative works of, display, perform, and distribute the Software and make, |
| 23 | + * use, sell, offer for sale, import, export, have made, and have sold the |
| 24 | + * Software and the Larger Work(s), and to sublicense the foregoing rights on |
| 25 | + * either these or other terms. |
| 26 | + * |
| 27 | + * This license is subject to the following condition: |
| 28 | + * |
| 29 | + * The above copyright notice and either this complete permission notice or at a |
| 30 | + * minimum a reference to the UPL must be included in all copies or substantial |
| 31 | + * portions of the Software. |
| 32 | + * |
| 33 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 34 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 35 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 36 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 37 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 38 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 39 | + * SOFTWARE. |
| 40 | + */ |
| 41 | +package org.graalvm.nativeimage.hosted; |
| 42 | + |
| 43 | +import org.graalvm.nativeimage.impl.TypeCondition; |
| 44 | + |
| 45 | +/** |
| 46 | + * Condition that must be satisfied for inclusion of elements for dynamic access (e.g., runtime |
| 47 | + * reflection, serialization, JNI access, and resource access at runtime). |
| 48 | + * {@link InclusionCondition} is used together with {@link Feature} for programmatic registration of |
| 49 | + * metadata. |
| 50 | + * <p> |
| 51 | + * Currently, there is only one type of condition: {@link #typeReached} that signifies that the type |
| 52 | + * must be both reachable by static analysis at build time, and reached at run time. A type is |
| 53 | + * reached at run time, right before the class-initialization routine starts for that type, or any |
| 54 | + * of the type's subtypes are reached. |
| 55 | + * </p> |
| 56 | + * |
| 57 | + * Conditions can be created via {@link #alwaysInclude} and {@link #typeReached} factory methods. |
| 58 | + */ |
| 59 | +public interface InclusionCondition { |
| 60 | + |
| 61 | + /** |
| 62 | + * Creates the type-reached condition that is always satisfied. Any element that is predicated |
| 63 | + * with this condition will always be included. |
| 64 | + * |
| 65 | + * @return instance of the condition |
| 66 | + */ |
| 67 | + static InclusionCondition alwaysInclude() { |
| 68 | + return TypeCondition.JAVA_LANG_OBJECT_REACHED; |
| 69 | + } |
| 70 | + |
| 71 | + /** |
| 72 | + * Creates the default type-reached condition that is satisfied when the type is reached at |
| 73 | + * runtime. |
| 74 | + * |
| 75 | + * @param type that has to be reached for this condition to be satisfied |
| 76 | + * @return instance of the condition |
| 77 | + */ |
| 78 | + static InclusionCondition typeReached(Class<?> type) { |
| 79 | + return TypeCondition.create(type, true); |
| 80 | + } |
| 81 | +} |
0 commit comments