[jdk8u-dev] RFR: 8345358: Some DLL Files are missing Windows Properties

Taizo Kurashige tkurashige at openjdk.org
Tue Aug 19 05:33:47 UTC 2025


On Tue, 22 Jul 2025 22:33:58 GMT, Alexey Bakhtin <abakhtin at openjdk.org> wrote:

>> Please review
>
>> Hi, @alexeybakhtin The reported issue doesn't seem to be resolved yet. Would you please move forward with this pull request?
> 
> There is a request to make a test. I'm not sure how to make jtreg test for this issue.

Hi, @alexeybakhtin

I propose the following code, which I made based on tkiriyama`s comment, as a test for this PR fix.

jdk/test/lib/property/CheckWindowsProperty.java

/*
 * 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.
 *
 * 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.
 */

/*
 * @test
 * @summary file property check for Windows .exe/.dll
 * @requires os.family == "windows"
 */

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class CheckWindowsProperty {
  public static void main(String[] args) throws Exception {
    String targetDir = System.getProperty("test.jdk") + "\";
    String psCommand = String.format(
        "Get-ChildItem -Path '%s' -include *.exe,*.dll -Recurse -File | " +
        "ForEach-Object { " +
            "$vi = $_.VersionInfo; " +
            "@($vi.FileName, $vi.CompanyName, $vi.FileDescription, $vi.FileVersion, " +
            "$vi.InternalName, $vi.Language, $vi.LegalCopyright, $vi.OriginalFilename, " +
            "$vi.ProductName, $vi.ProductVersion) -join ';'" +
        "}",
        targetDir
    );

    ProcessBuilder pb = new ProcessBuilder("powershell", "-NoLogo", "-NoProfile",
         "-Command", psCommand).redirectErrorStream(true);
    Process p = pb.start();
    p.getOutputStream().close();

    try (BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()))) {
        for (String line = br.readLine(); line != null; line = br.readLine()) {
            checkFileProperty(line);
        }
    }
    p.waitFor();
    int exitCode = p.exitValue();
    if (exitCode != 0) {
        throw new RuntimeException("ExitCode is " + exitCode + ". PowerShell command failed.");
    }
  }

  static void checkFileProperty(String line) {
    // line format
    // FileName;CompanyName;FileDescription;FileVersion;InternalName;Language;LegalCopyright;
    // OriginalFilename;ProductName;ProductVersion
    String[] data = line.split(";", -1);
    String filename = data[0].substring(data[0].lastIndexOf(System.getProperty("file.separator")) + 1);

    // skip Microsoft redist dll
    if (filename.startsWith("api-ms-win") ||
        filename.startsWith("msvcp") ||
        filename.startsWith("ucrtbase") ||
        filename.startsWith("vcruntime")) {
        return;
    }

    if (filename.equals("freetype.dll") || filename.equals("sawindbg.dll")) {
        for (int i = 1; i < data.length; i++) {
            if (data[i] == null || !data[i].isEmpty()) {
                throw new RuntimeException(data[i] +" is set in data[" + i + "]. data[" + i + "] should be empty for " + filename);
            }
        }
    } else {
        for (int i = 1; i < data.length; i++) {
            if (data[i] == null || data[i].isEmpty()) {
                throw new RuntimeException("data[" + i + "] should not be empty for " + filename);
            }
        }
    }
  }
}



I confirmed that the test result is as follows:

when this PR fix is not applied

FAILED: lib/property/CheckWindowsProperty.java
Test results: failed: 1


----------System.err:(13/752)----------
java.lang.RuntimeException: data[1] should not be empty for j2gss.dll
	at CheckWindowsProperty.checkFileProperty(CheckWindowsProperty.java:88)
	at CheckWindowsProperty.main(CheckWindowsProperty.java:54)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:312)
	at java.lang.Thread.run(Thread.java:750)



when this PR fixis applied

Passed: lib/property/CheckWindowsProperty.java
Test results: passed: 1


I hope this is helpful.

-------------

PR Comment: https://git.openjdk.org/jdk8u-dev/pull/611#issuecomment-3199258589


More information about the jdk8u-dev mailing list