Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 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
Expand All @@ -25,11 +25,13 @@
package jdk.tools.jlink.internal.plugins;

import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.UncheckedIOException;
import java.lang.module.ModuleDescriptor;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -107,8 +109,8 @@ public void configure(Map<String, String> config) {
default: {
// --release-info <file>
Properties props = new Properties();
try (FileInputStream fis = new FileInputStream(operation)) {
props.load(fis);
try (Reader reader = Files.newBufferedReader(Path.of(operation))) {
props.load(reader); // Use reader API so as to read in as UTF-8
} catch (IOException exp) {
throw new UncheckedIOException(exp);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2015, 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
Expand Down Expand Up @@ -39,14 +39,16 @@ release-info.argument=<file>|add:<key1>=<value1>:<key2>=<value2>:...|del:<key li

release-info.description=\
<file> option is to load release properties from the supplied file.\n\
\ The specified file is expected to be encoded in UTF-8.\n\
add: is to add properties to the 'release' file.\n\
Any number of <key>=<value> pairs can be passed.\n\
del: is to delete the list of keys in release file.

release-info.usage=\
\ --release-info <file>|add:<key1>=<value1>:<key2>=<value2>:...|del:<key list>\n\
\ <file> option is to load release properties from\n\
\ the supplied file.\n\
\ the supplied file. The specified file is expected\n\
\ to be encoded in UTF-8.\n\
\ add: is to add properties to the 'release' file.\n\
\ Any number of <key>=<value> pairs can be passed.\n\
\ del: is to delete the list of keys in release file.
Expand Down
82 changes: 82 additions & 0 deletions test/jdk/tools/jlink/plugins/ReleaseInfoPluginTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright (c) 2025, IBM Corporation. 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.
*
* 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.
*/

import jdk.test.lib.process.*;
import jdk.test.lib.Asserts;

import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Files;
import java.util.Properties;

import jdk.tools.jlink.internal.LinkableRuntimeImage;

import tests.Helper;

/* @test
* @bug 8372155
* @summary Test the --release-info <file> plugin option
* @library ../../lib
* @library /test/lib
* @modules jdk.jlink/jdk.tools.jlink.internal
* jdk.jlink/jdk.tools.jimage
* java.base/jdk.internal.jimage
* @build tests.*
* @run main/othervm ReleaseInfoPluginTest
*/

public class ReleaseInfoPluginTest {

private static final String NON_ASCII = "ößäakl vendor oy";
private static final String IMPL = "IMPLEMENTOR";
private static final boolean LINKABLE_RUNTIME = LinkableRuntimeImage.isLinkableRuntime();

public static void main(String[] args) throws Throwable {

Helper helper = Helper.newHelper(LINKABLE_RUNTIME);
if (helper == null) {
System.err.println("Test not run");
return;
}
var utf8File = Path.of("release-info-utf-8.txt");
Files.writeString(utf8File, IMPL + "=\"" + NON_ASCII + "\"", StandardCharsets.UTF_8);
var image = helper.generateDefaultImage(
new String[] {
"--release-info", utf8File.toString()
}, "java.base").assertSuccess();

// release file produced should have IMPLEMENTOR in
// UTF-8 encoding
var release = image.resolve("release");
Properties props = new Properties();
try (Reader reader= Files.newBufferedReader(release)) {
props.load(reader); // Load as UTF-8
}
String noQuotesMods = ((String)props.get("MODULES")).replace("\"", "");
Asserts.assertEquals("java.base", noQuotesMods);
String noQuotesActual = ((String)props.get(IMPL)).replace("\"", "");
Asserts.assertEquals(NON_ASCII, noQuotesActual);
}

}