Skip to content

Commit dbaa7ac

Browse files
7903846: apidiff: test issues on Windows
Reviewed-by: cstein, iris
1 parent bb3eb15 commit dbaa7ac

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

test/junit/apitest/GetSerialVersionUIDTest.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -91,7 +91,7 @@ public static Stream<Arguments> provideLocalClasses() {
9191
@MethodSource("provideLocalClasses")
9292
public void testLocal(String interfaces, String members) throws Exception {
9393
log.printf("interfaces: %s; members: %s%n", interfaces, members);
94-
Path base = getScratchDir().resolve(getDirectory(interfaces, members));
94+
Path base = getScratchDir(getSubdirectoryName(interfaces, members));
9595
log.println(base);
9696

9797
Path src = Files.createDirectories(base.resolve("src"));
@@ -154,16 +154,18 @@ public void testSystemClass(String name) throws Exception {
154154
Assertions.assertEquals(platformSerialVersionUID, classSerialVersionUID, "serialVersionUID from class");
155155
}
156156

157-
Path getDirectory(String interfaces, String members) {
157+
String getSubdirectoryName(String interfaces, String members) {
158158
String i = Stream.of(interfaces.split("\\s+"))
159159
.map(s -> s.substring(s.lastIndexOf(".") + 1))
160160
.collect(Collectors.joining("-"));
161-
String m = Stream.of(members.split(";\\s*"))
162-
.map(s -> s.replaceAll("=.*", ""))
163-
.map(s -> s.substring(s.lastIndexOf(" ") + 1))
164-
.collect(Collectors.joining("-"));
161+
// allow for all kinds of members: not just fields
162+
String m = members.replaceAll("[^A-Za-z0-9]+", "-");
163+
int MAX_MEMBER_LENGTH = 32;
164+
if (m.length() > MAX_MEMBER_LENGTH) {
165+
m = m.substring(0, MAX_MEMBER_LENGTH);
166+
}
165167
String sep = i.isEmpty() || m.isEmpty() ? "" : "-";
166-
return Path.of(i + sep + m);
168+
return i + sep + m;
167169
}
168170

169171
long getPlatformSerialVersionUID(Path classes, String name) throws Exception {

0 commit comments

Comments
 (0)