|
| 1 | +/* |
| 2 | + * Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved. |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | + * |
| 5 | + * This code is free software; you can redistribute it and/or modify it |
| 6 | + * under the terms of the GNU General Public License version 2 only, as |
| 7 | + * published by the Free Software Foundation. Oracle designates this |
| 8 | + * particular file as subject to the "Classpath" exception as provided |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. |
| 10 | + * |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that |
| 15 | + * accompanied this code). |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU General Public License version |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | + * |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 22 | + * or visit www.oracle.com if you need additional information or have any |
| 23 | + * questions. |
| 24 | + */ |
| 25 | +package com.oracle.svm.core.util; |
| 26 | + |
| 27 | +import java.lang.annotation.ElementType; |
| 28 | +import java.lang.annotation.Repeatable; |
| 29 | +import java.lang.annotation.Retention; |
| 30 | +import java.lang.annotation.RetentionPolicy; |
| 31 | +import java.lang.annotation.Target; |
| 32 | + |
| 33 | +import org.graalvm.nativeimage.Platform; |
| 34 | +import org.graalvm.nativeimage.Platforms; |
| 35 | + |
| 36 | +/** |
| 37 | + * Documents that the element is based on a JDK source file. This is mainly useful for non-Java |
| 38 | + * sources like C++ files. For Java classes, {@link BasedOnJDKClass} might be more appropriate. |
| 39 | + */ |
| 40 | +@Repeatable(BasedOnJDKFile.List.class) |
| 41 | +@Retention(RetentionPolicy.RUNTIME) |
| 42 | +@Target(value = {ElementType.TYPE, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.METHOD}) |
| 43 | +@Platforms(Platform.HOSTED_ONLY.class) |
| 44 | +public @interface BasedOnJDKFile { |
| 45 | + |
| 46 | + /** |
| 47 | + * Path to the source file relative to the repository root (usually |
| 48 | + * <a href="https://github.com/openjdk/jdk">openjdk</a>). The path elements must be separated by |
| 49 | + * slashes ({@code /}) and since it is a relative path, it must not start with a slash. |
| 50 | + * |
| 51 | + * To specify a line range, a suffix of the form {@code #L[0-9]+-L[0-9]+} might be added. Full |
| 52 | + * example: |
| 53 | + * |
| 54 | + * <pre> |
| 55 | + * @BasedOnJDKFile("src/hotspot/cpu/x86/vm_version_x86.hpp#L40-L304") |
| 56 | + * </pre> |
| 57 | + * |
| 58 | + * The path and line numbers always apply to the latest supported JDK version. That version can |
| 59 | + * be retrieved from the {@code jdks.oraclejdk-latest} entry from {@code common.json} in the |
| 60 | + * root of this repository, or by looking up the latest version in the |
| 61 | + * {@code JVMCI_MIN_VERSIONS} map in {@link jdk.graal.compiler.hotspot.JVMCIVersionCheck}. At |
| 62 | + * the time of writing this is {@code jdk-23+8} (formatted as a git tag as used by the openjdk). |
| 63 | + * That information can also be used to view the respective line range on GitHub via |
| 64 | + * {@code https://github.com/openjdk/jdk/blob/<version-tag>/<value>}. For the example above, it |
| 65 | + * would translate to <a href= |
| 66 | + * "https://github.com/openjdk/jdk/blob/jdk-23+8/src/hotspot/cpu/x86/vm_version_x86.hpp#L40-L304"> |
| 67 | + * {@code https://github.com/openjdk/jdk/blob/jdk-23+8/src/hotspot/cpu/x86/vm_version_x86.hpp#L40-L304}</a> |
| 68 | + */ |
| 69 | + String value(); |
| 70 | + |
| 71 | + /** |
| 72 | + * Support for making {@link BasedOnJDKFile} {@linkplain Repeatable repeatable}. |
| 73 | + */ |
| 74 | + @Retention(RetentionPolicy.RUNTIME) |
| 75 | + @Target(value = {ElementType.TYPE, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.METHOD}) |
| 76 | + @Platforms(Platform.HOSTED_ONLY.class) |
| 77 | + @interface List { |
| 78 | + BasedOnJDKFile[] value(); |
| 79 | + } |
| 80 | +} |
0 commit comments