Update to use correct library directories

See also: https://openjdk.org/jtreg/faq.html#how-do-i-find-the-path-for-the-testng-or-junit-jar-files
This commit is contained in:
Christian Stein 2025-08-11 13:29:26 +02:00
parent bf7b033b6f
commit b5112c32dd
2 changed files with 11 additions and 22 deletions

View file

@ -25,9 +25,10 @@ package nsk.jvmti.ResourceExhausted;
import java.io.File;
import java.io.FileInputStream;
import java.io.PrintStream;
import java.net.URI;
import java.nio.file.Path;
import java.security.CodeSource;
import java.security.ProtectionDomain;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import nsk.share.Consts;
import nsk.share.test.Stresser;
@ -80,24 +81,12 @@ public class resexhausted003 {
public static int run(String args[], PrintStream out) {
String testclasspath = System.getProperty("test.class.path");
String [] testpaths = testclasspath.split(System.getProperty("path.separator"));
String classesDir = "";
Pattern pattern = Pattern.compile("^(.*)classes(.*)vmTestbase(.*)$");
for (int i = 0 ; i < testpaths.length; i++) {
if (pattern.matcher(testpaths[i]).matches()) {
classesDir = testpaths[i];
}
}
if (classesDir.equals("")) {
System.err.println("TEST BUG: Classes directory not found in test,class.path.");
return Consts.TEST_FAILED;
}
Stresser stress = new Stresser(args);
String className = Helper.class.getName();
byte[] bloatBytes = fileBytes(classesDir + File.separator + className.replace('.', '/') + ".class");
CodeSource classCodeSource = Helper.class.getProtectionDomain().getCodeSource();
Path classFilePath = Path.of(URI.create(classCodeSource.getLocation().toString()));
byte[] bloatBytes = fileBytes(classFilePath.resolve(className.replace('.', '/') + ".class").toString());
int count = 0;
Helper.resetExhaustedEvent();

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Red Hat, Inc.
* Copyright (c) 2022, 2025, Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -30,6 +30,7 @@ import java.util.Calendar;
import java.util.Locale;
import java.util.List;
import java.util.ArrayList;
import java.net.URI;
import java.nio.file.Paths;
import java.nio.file.Path;
import java.nio.file.Files;
@ -54,12 +55,9 @@ import static java.util.Calendar.WEDNESDAY;
*/
public class TestSPISigned {
private static final String TEST_CLASSES = System.getProperty("test.classes", ".");
private static final String TEST_SRC = System.getProperty("test.src", ".");
private static final Path META_INF_DIR = Paths.get(TEST_SRC, "provider", "meta");
private static final Path PROVIDER_PARENT = Paths.get(TEST_CLASSES, "..");
private static final Path PROVIDER_DIR = PROVIDER_PARENT.resolve("provider");
private static final Path MODS_DIR = Paths.get("mods");
private static final Path UNSIGNED_JAR = MODS_DIR.resolve("unsigned-with-locale.jar");
private static final Path SIGNED_JAR = MODS_DIR.resolve("signed-with-locale.jar");
@ -81,7 +79,9 @@ public class TestSPISigned {
// Set up signed jar with custom calendar data provider
//
// 1. Create jar with custom CalendarDataProvider
JarUtils.createJarFile(UNSIGNED_JAR, PROVIDER_DIR);
var codeSource = baz.CalendarDataProviderImpl.class.getProtectionDomain().getCodeSource();
var providerDir = Path.of(URI.create(codeSource.getLocation().toString()));
JarUtils.createJarFile(UNSIGNED_JAR, providerDir);
JarUtils.updateJarFile(UNSIGNED_JAR, META_INF_DIR);
// create signer's keypair
SecurityTools.keytool("-genkeypair -keyalg RSA -keystore ks " +