Skip to content

Commit

Permalink
8323664: java/awt/font/JNICheck/FreeTypeScalerJNICheck.java still fai…
Browse files Browse the repository at this point in the history
…ls with JNI warning on some Windows configurations

Reviewed-by: prr, mbaesken, aivanov
  • Loading branch information
RealCLanger committed Feb 15, 2024
1 parent 0fdfdf7 commit 99c9ae1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
21 changes: 10 additions & 11 deletions src/java.desktop/windows/native/libawt/windows/awt_Debug.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2024, 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 @@ -153,21 +153,20 @@ AwtDebugSupport::~AwtDebugSupport() {
static jboolean isHeadless() {
jmethodID headlessFn;
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
jclass graphicsEnvClass = env->FindClass(
"java/awt/GraphicsEnvironment");
// be on the safe side and avoid JNI warnings by calling ExceptionCheck
// an accumulated exception is not cleared
env->ExceptionCheck();
jclass graphicsEnvClass = env->FindClass("java/awt/GraphicsEnvironment");

if (graphicsEnvClass != NULL) {
headlessFn = env->GetStaticMethodID(
graphicsEnvClass, "isHeadless", "()Z");
headlessFn = env->GetStaticMethodID(graphicsEnvClass, "isHeadless", "()Z");
if (headlessFn != NULL) {
return env->CallStaticBooleanMethod(graphicsEnvClass,
headlessFn);
return env->CallStaticBooleanMethod(graphicsEnvClass, headlessFn);
}
}
return true;
}


void AwtDebugSupport::AssertCallback(const char * expr, const char * file, int line) {
static const int ASSERT_MSG_SIZE = 1024;
static const char * AssertFmt =
Expand All @@ -177,9 +176,9 @@ void AwtDebugSupport::AssertCallback(const char * expr, const char * file, int l
"Do you want to break into the debugger?";

static char assertMsg[ASSERT_MSG_SIZE+1];
DWORD lastError = GetLastError();
LPSTR msgBuffer = NULL;
int ret = IDNO;
DWORD lastError = GetLastError();
LPSTR msgBuffer = NULL;
int ret = IDNO;
static jboolean headless = isHeadless();

DWORD fret= FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
Expand Down
11 changes: 6 additions & 5 deletions test/jdk/java/awt/font/JNICheck/FreeTypeScalerJNICheck.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, JetBrains s.r.o.. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -45,7 +45,10 @@ public static void main(String[] args) throws Exception {
} else {
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder("-Xcheck:jni", FreeTypeScalerJNICheck.class.getName(), "runtest");
OutputAnalyzer oa = ProcessTools.executeProcess(pb);
oa.shouldContain("Done").shouldNotContain("WARNING").shouldHaveExitValue(0);
oa.shouldContain("Done")
.shouldNotContain("WARNING")
.shouldNotContain("AWT Assertion")
.shouldHaveExitValue(0);
}
}

Expand All @@ -54,8 +57,7 @@ public static void runTest() {
BufferedImage bi = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = bi.createGraphics();

for (String ff : families)
{
for (String ff : families) {
Font font = new Font(ff, Font.PLAIN, 12);
Rectangle2D bounds = font.getStringBounds("test", g2d.getFontRenderContext());
g2d.setFont(font);
Expand All @@ -66,4 +68,3 @@ public static void runTest() {
System.out.println("Done");
}
}

6 comments on commit 99c9ae1

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RealCLanger
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk22u

@openjdk
Copy link

@openjdk openjdk bot commented on 99c9ae1 Feb 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RealCLanger the backport was successfully created on the branch backport-RealCLanger-99c9ae12 in my personal fork of openjdk/jdk22u. To create a pull request with this backport targeting openjdk/jdk22u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 99c9ae12 from the openjdk/jdk repository.

The commit being backported was authored by Christoph Langer on 15 Feb 2024 and was reviewed by Phil Race, Matthias Baesken and Alexey Ivanov.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk22u:

$ git fetch https://github.com/openjdk-bots/jdk22u.git backport-RealCLanger-99c9ae12:backport-RealCLanger-99c9ae12
$ git checkout backport-RealCLanger-99c9ae12
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk22u.git backport-RealCLanger-99c9ae12

@RealCLanger
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 99c9ae1 Feb 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RealCLanger the backport was successfully created on the branch backport-RealCLanger-99c9ae12 in my personal fork of openjdk/jdk21u-dev. To create a pull request with this backport targeting openjdk/jdk21u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 99c9ae12 from the openjdk/jdk repository.

The commit being backported was authored by Christoph Langer on 15 Feb 2024 and was reviewed by Phil Race, Matthias Baesken and Alexey Ivanov.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u-dev:

$ git fetch https://github.com/openjdk-bots/jdk21u-dev.git backport-RealCLanger-99c9ae12:backport-RealCLanger-99c9ae12
$ git checkout backport-RealCLanger-99c9ae12
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u-dev.git backport-RealCLanger-99c9ae12

@openjdk
Copy link

@openjdk openjdk bot commented on 99c9ae1 Feb 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RealCLanger Could not automatically backport 99c9ae12 to openjdk/jdk17u-dev due to conflicts in the following files:

  • test/jdk/java/awt/font/JNICheck/FreeTypeScalerJNICheck.java

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk17u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk17u-dev.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b backport-RealCLanger-99c9ae12

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git 99c9ae127c0a3b8c4fc6ede87079ff7c693a2905

# Backport the commit
$ git cherry-pick --no-commit 99c9ae127c0a3b8c4fc6ede87079ff7c693a2905
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 99c9ae127c0a3b8c4fc6ede87079ff7c693a2905'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk17u-dev with the title Backport 99c9ae127c0a3b8c4fc6ede87079ff7c693a2905.

Below you can find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 99c9ae12 from the openjdk/jdk repository.

The commit being backported was authored by Christoph Langer on 15 Feb 2024 and was reviewed by Phil Race, Matthias Baesken and Alexey Ivanov.

Thanks!

Please sign in to comment.