Skip to content

Commit bf8c645

Browse files
committed
Added SuppressForbidden annotation.
1 parent d47f794 commit bf8c645

File tree

6 files changed

+32
-6
lines changed

6 files changed

+32
-6
lines changed

independent-projects/arc/processor/pom.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@
7676
<signaturesFile>./banned-signatures.txt</signaturesFile>
7777
</signaturesFiles>
7878
<ignoreSignaturesOfMissingClasses>true</ignoreSignaturesOfMissingClasses>
79+
<suppressAnnotations>
80+
<annotation>**.SuppressForbidden</annotation>
81+
</suppressAnnotations>
7982
</configuration>
8083
<phase>compile</phase>
8184
<goals>

independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/ComponentsProviderGenerator.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ void invokeAddMethod() {
551551
}
552552

553553
@Override
554+
@SuppressForbidden(reason = "Using Type.toString() to build an informative message")
554555
void addComponentInternal(BeanInfo removedBean) {
555556

556557
ResultHandle removedBeansHandle = addMethod.getMethodParam(0);
@@ -567,7 +568,7 @@ void addComponentInternal(BeanInfo removedBean) {
567568
CatchBlockCreator catchBlock = tryBlock.addCatch(Throwable.class);
568569
catchBlock.invokeStaticInterfaceMethod(
569570
MethodDescriptors.COMPONENTS_PROVIDER_UNABLE_TO_LOAD_REMOVED_BEAN_TYPE,
570-
catchBlock.load(type.name().toString()), catchBlock.getCaughtException());
571+
catchBlock.load(type.toString()), catchBlock.getCaughtException());
571572
AssignableResultHandle typeHandle = tryBlock.createVariable(Object.class);
572573
try {
573574
Types.getTypeHandle(typeHandle, tryBlock, type, tccl, typeCache);
@@ -654,13 +655,15 @@ public void initialize(MethodCreator method) {
654655
}
655656

656657
@Override
658+
@SuppressForbidden(reason = "Using Type.toString() to build an informative message")
657659
public ResultHandle get(org.jboss.jandex.Type type, BytecodeCreator bytecode) {
658-
return bytecode.invokeInterfaceMethod(MethodDescriptors.MAP_GET, mapHandle, bytecode.load(type.name().toString()));
660+
return bytecode.invokeInterfaceMethod(MethodDescriptors.MAP_GET, mapHandle, bytecode.load(type.toString()));
659661
}
660662

661663
@Override
664+
@SuppressForbidden(reason = "Using Type.toString() to build an informative message")
662665
public void put(org.jboss.jandex.Type type, ResultHandle value, BytecodeCreator bytecode) {
663-
bytecode.invokeInterfaceMethod(MethodDescriptors.MAP_PUT, mapHandle, bytecode.load(type.name().toString()), value);
666+
bytecode.invokeInterfaceMethod(MethodDescriptors.MAP_PUT, mapHandle, bytecode.load(type.toString()), value);
664667
}
665668

666669
}

independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/InvokerGenerator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,13 +791,14 @@ static class CandidateMethods {
791791
this.invoker = invoker;
792792
}
793793

794+
@SuppressForbidden(reason = "Using Type.toString() to build an informative message")
794795
CandidateMethod resolve() {
795796
if (matching.size() == 1) {
796797
return matching.get(0);
797798
}
798799

799800
if (matching.isEmpty()) {
800-
String expectedType = this.expectedType.name().toString();
801+
String expectedType = this.expectedType.toString();
801802
String expectation = "";
802803
if (transformer.isInputTransformer()) {
803804
expectation = "\n"

independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/ObserverGenerator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public ObserverGenerator(AnnotationLiteralProcessor annotationLiterals, Predicat
9494
*
9595
* @param observer
9696
*/
97+
@SuppressForbidden(reason = "Using Type.toString() to build an informative message")
9798
void precomputeGeneratedName(ObserverInfo observer) {
9899
// The name of the generated class differs:
99100
// "org.acme.Foo_Observer_fooMethod_hash" for normal observer where hash represents the signature of the observer method
@@ -117,7 +118,7 @@ void precomputeGeneratedName(ObserverInfo observer) {
117118
if (observer.getId() != null) {
118119
sigBuilder.append(observer.getId());
119120
}
120-
sigBuilder.append(observer.getObservedType().name().toString()).append(observer.getQualifiers().toString())
121+
sigBuilder.append(observer.getObservedType().toString()).append(observer.getQualifiers().toString())
121122
.append(observer.isAsync()).append(observer.getPriority()).append(observer.getTransactionPhase());
122123
} else {
123124
sigBuilder.append(observer.getObserverMethod().name())
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package io.quarkus.arc.processor;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
import java.lang.annotation.Target;
7+
8+
/**
9+
* Used to suppress forbidden-apis errors inside the element it's added to.
10+
*/
11+
@Retention(RetentionPolicy.CLASS)
12+
@Target({ ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD, ElementType.TYPE })
13+
public @interface SuppressForbidden {
14+
String reason();
15+
}

independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/bcextensions/TypeImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
import org.jboss.jandex.DotName;
1414

15+
import io.quarkus.arc.processor.SuppressForbidden;
16+
1517
abstract class TypeImpl<JandexType extends org.jboss.jandex.Type> extends AnnotationTargetImpl implements Type {
1618
final JandexType jandexType;
1719

@@ -108,7 +110,8 @@ public Collection<AnnotationInfo> annotations() {
108110
}
109111

110112
@Override
113+
@SuppressForbidden(reason = "Using Type.toString() to build an informative message")
111114
public String toString() {
112-
return jandexType.name().toString();
115+
return jandexType.toString();
113116
}
114117
}

0 commit comments

Comments
 (0)