-
Notifications
You must be signed in to change notification settings - Fork 127
8371292: [lworld] Switch JLink to not use ImageReader API #1721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1cc77d4
3fcfea6
a433f09
67984e2
a2f0c0c
fdcb73f
e52692f
533e5af
7263e2e
8e702fa
1f85ff7
726ace9
de2c1be
493930d
dffe937
a27a288
aac5c9e
8567038
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| /* | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a copy of the notice in BasicImageReader, so I assume the clause about the GPL is correct. |
||
| * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. | ||
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| * | ||
| * This code is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU General Public License version 2 only, as | ||
| * published by the Free Software Foundation. Oracle designates this | ||
| * particular file as subject to the "Classpath" exception as provided | ||
| * by Oracle in the LICENSE file that accompanied this code. | ||
| * | ||
| * This code is distributed in the hope that it will be useful, but WITHOUT | ||
| * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| * version 2 for more details (a copy is included in the LICENSE file that | ||
| * accompanied this code). | ||
| * | ||
| * You should have received a copy of the GNU General Public License version | ||
| * 2 along with this work; if not, write to the Free Software Foundation, | ||
| * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| * | ||
| * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
| * or visit www.oracle.com if you need additional information or have any | ||
| * questions. | ||
| */ | ||
| package jdk.internal.jimage; | ||
|
|
||
| import java.io.InputStream; | ||
| import java.util.stream.Stream; | ||
|
|
||
| /** | ||
| * Accesses the underlying resource entries in a jimage file. | ||
| * | ||
| * <p>This API is designed only for use by the jlink classes, which read the raw | ||
| * jimage files. Use the {@link ImageReader} API to read jimage contents at | ||
| * runtime to correctly account for preview mode. | ||
| * | ||
| * <p>This API ignores the {@code previewMode} of the {@link ImageReader} from | ||
| * which it is obtained, and returns an unmapped view of entries (e.g. allowing | ||
| * for direct access of resources in the {@code META-INF/preview/...} namespace). | ||
| * | ||
| * <p>It disallows access to resource directories (i.e. {@code "/modules/..."}) | ||
| * or packages entries (i.e. {@code "/packages/..."}). | ||
| * | ||
| * @implNote This class needs to maintain JDK 8 source compatibility. | ||
| * | ||
| * It is used internally in the JDK to implement jimage/jrtfs access, | ||
| * but also compiled and delivered as part of the jrtfs.jar to support access | ||
| * to the jimage file provided by the shipped JDK by tools running on JDK 8. | ||
| */ | ||
| public interface ResourceEntries { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an API so that we can avoid using ImageReader directly in the jlink code. |
||
| /** | ||
| * Returns the jimage names for all resources in the given module, in | ||
| * random order. Entry names will always be prefixed by the given module | ||
| * name (e.g. {@code "/<module-name>/..."}). | ||
| */ | ||
| Stream<String> getEntryNames(String module); | ||
|
|
||
| /** | ||
| * Returns the (uncompressed) size of a resource given its jimage name. | ||
| * | ||
| * @throws java.util.NoSuchElementException if the resource does not exist. | ||
| */ | ||
| long getSize(String name); | ||
|
|
||
| /** | ||
| * Returns a copy of a resource's content given its jimage name. | ||
| * | ||
| * @throws java.util.NoSuchElementException if the resource does not exist. | ||
| */ | ||
| byte[] getBytes(String name); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ | |
| */ | ||
| package jdk.tools.jlink.internal; | ||
|
|
||
| import java.io.Closeable; | ||
| import java.io.IOException; | ||
| import java.io.InputStream; | ||
| import java.nio.file.Path; | ||
|
|
@@ -34,7 +35,7 @@ | |
| * An Archive of all content, classes, resources, configuration files, and | ||
| * other, for a module. | ||
| */ | ||
| public interface Archive { | ||
| public interface Archive extends Closeable { | ||
david-beaumont marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Entry is contained in an Archive | ||
|
|
@@ -59,11 +60,12 @@ public static enum EntryType { | |
| private final String path; | ||
|
|
||
| /** | ||
| * Constructs an entry of the given archive | ||
| * @param archive archive | ||
| * @param path | ||
| * @param name an entry name that does not contain the module name | ||
| * @param type | ||
| * Constructs an entry of the given archive. | ||
| * | ||
| * @param archive the archive in which this entry exists. | ||
| * @param path the complete path of the entry, including the module. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that now I removed the path() method I added, the path passed here serves absolutely no purpose other than to appear in the toString() output. I'd vote for removing it completely and simplifying callers. |
||
| * @param name an entry name relative to its containing module. | ||
| * @param type the entry type. | ||
| */ | ||
| public Entry(Archive archive, String path, String name, EntryType type) { | ||
| this.archive = Objects.requireNonNull(archive); | ||
|
|
@@ -72,10 +74,6 @@ public Entry(Archive archive, String path, String name, EntryType type) { | |
| this.type = Objects.requireNonNull(type); | ||
| } | ||
|
|
||
| public final Archive archive() { | ||
| return archive; | ||
| } | ||
|
|
||
| public final EntryType type() { | ||
| return type; | ||
| } | ||
|
|
@@ -134,5 +132,6 @@ public String toString() { | |
| /* | ||
| * Close the archive | ||
| */ | ||
| @Override | ||
| void close() throws IOException; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the implementation of the new, narrow, API. That's it.