Skip to content

Commit

Permalink
8292182: [TESTLIB] Enhance JAXPPolicyManager to setup required permis…
Browse files Browse the repository at this point in the history
…sions for jtreg version 7 jar

Reviewed-by: joehw, lancea, iris, naoto
  • Loading branch information
sormuras authored and Lance Andersen committed Aug 15, 2022
1 parent 695bb39 commit aa5b718
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2022, 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 @@ -23,7 +23,9 @@
package jaxp.library;


import java.net.URI;
import java.net.URL;
import java.nio.file.Path;
import java.security.CodeSource;
import java.security.Permission;
import java.security.PermissionCollection;
Expand Down Expand Up @@ -161,7 +163,7 @@ void removeTmpPermission(int index) {
*/
class TestPolicy extends Policy {
private final static Set<String> TEST_JARS =
Set.of("jtreg.jar", "javatest.jar", "testng.jar", "jcommander.jar");
Set.of("jtreg.*jar", "javatest.*jar", "testng.*jar", "jcommander.*jar");
private final PermissionCollection permissions = new Permissions();

private ThreadLocal<Map<Integer, Permission>> transientPermissions = new ThreadLocal<>();
Expand Down Expand Up @@ -213,9 +215,10 @@ public PermissionCollection getPermissions(CodeSource codesource) {
private boolean isTestMachineryDomain(ProtectionDomain domain) {
CodeSource cs = (domain == null) ? null : domain.getCodeSource();
URL loc = (cs == null) ? null : cs.getLocation();
String path = (loc == null) ? null : loc.getPath();
return path != null && TEST_JARS.stream()
.filter(path::endsWith)
URI uri = (loc == null) ? null : URI.create(loc.toString());
String name = (uri == null) ? null : Path.of(uri).getFileName().toString();
return name != null && TEST_JARS.stream()
.filter(name::matches)
.findAny()
.isPresent();
}
Expand Down

3 comments on commit aa5b718

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on aa5b718 Jun 22, 2023

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on aa5b718 Jun 22, 2023

Choose a reason for hiding this comment

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

@GoeLin the backport was successfully created on the branch GoeLin-backport-aa5b7189 in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-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 aa5b7189 from the openjdk/jdk repository.

The commit being backported was authored by Christian Stein on 15 Aug 2022 and was reviewed by Joe Wang, Lance Andersen, Iris Clark and Naoto Sato.

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/jdk17u-dev:

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

Please sign in to comment.