Skip to content

Commit 7b693b4

Browse files
committed
Fix annotation processing test with pattern declarations
1 parent d027520 commit 7b693b4

File tree

2 files changed

+47
-19
lines changed

2 files changed

+47
-19
lines changed

test/langtools/tools/javac/processing/model/element/TestPatternDeclarationExecutableElement.java

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
* @modules java.compiler
3030
* jdk.compiler
3131
* @enablePreview
32-
* @build JavacTestingAbstractProcessor TestPatternDeclarationExecutableElement
33-
* @compile --enable-preview --source ${jdk.version} -processor TestPatternDeclarationExecutableElement -proc:only TestPatternDeclarationExecutableElement.java
32+
* @build JavacTestingAbstractProcessor
33+
* @compile TestPatternDeclarationExecutableElement.java
34+
* @compile --enable-preview --source ${jdk.version} -processor TestPatternDeclarationExecutableElement -proc:only TestPatternDeclarationExecutableElementData.java
3435
*/
3536

3637
import javax.annotation.processing.RoundEnvironment;
@@ -66,7 +67,7 @@ public boolean process(Set<? extends TypeElement> annotations,
6667
var bindings = pattern.getBindings();
6768
var type = pattern.asType();
6869

69-
if (!simpleName.contentEquals("TestPatternDeclarationExecutableElement"))
70+
if (!simpleName.contentEquals("TestPatternDeclarationExecutableElementData"))
7071
throw new RuntimeException("Unexpected name for deconstructor " + simpleName);
7172

7273
if (!(returnType instanceof NoType))
@@ -87,20 +88,4 @@ public boolean process(Set<? extends TypeElement> annotations,
8788
}
8889
return true;
8990
}
90-
91-
public pattern TestPatternDeclarationExecutableElement(String name) {
92-
if (capitalize) {
93-
match TestPatternDeclarationExecutableElement(this.name.toUpperCase());
94-
} else {
95-
match TestPatternDeclarationExecutableElement(this.name);
96-
}
97-
}
98-
99-
public pattern TestPatternDeclarationExecutableElement(String originalName, String editedName) {
100-
if (capitalize) {
101-
match TestPatternDeclarationExecutableElement(this.name, this.name.toUpperCase());
102-
} else {
103-
match TestPatternDeclarationExecutableElement(this.name, this.name);
104-
}
105-
}
10691
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
public class TestPatternDeclarationExecutableElementData {
25+
private final String name = "Name";
26+
private boolean capitalize = false;
27+
28+
public pattern TestPatternDeclarationExecutableElementData(String name) {
29+
if (capitalize) {
30+
match TestPatternDeclarationExecutableElementData(this.name.toUpperCase());
31+
} else {
32+
match TestPatternDeclarationExecutableElementData(this.name);
33+
}
34+
}
35+
36+
public pattern TestPatternDeclarationExecutableElementData(String originalName, String editedName) {
37+
if (capitalize) {
38+
match TestPatternDeclarationExecutableElementData(this.name, this.name.toUpperCase());
39+
} else {
40+
match TestPatternDeclarationExecutableElementData(this.name, this.name);
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)