Skip to content

Commit 871f253

Browse files
authored
[Entitlements] Use the correct format for the EntitlementInstrumented annotation descriptor (#124310) (#124401)
1 parent 652d750 commit 871f253

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

libs/entitlement/asm-provider/src/main/java/org/elasticsearch/entitlement/instrumentation/impl/InstrumenterImpl.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
package org.elasticsearch.entitlement.instrumentation.impl;
1111

1212
import org.elasticsearch.entitlement.instrumentation.CheckMethod;
13+
import org.elasticsearch.entitlement.instrumentation.EntitlementInstrumented;
1314
import org.elasticsearch.entitlement.instrumentation.Instrumenter;
1415
import org.elasticsearch.entitlement.instrumentation.MethodKey;
1516
import org.elasticsearch.logging.LogManager;
@@ -92,7 +93,7 @@ public byte[] instrumentClass(String className, byte[] classfileBuffer) {
9293

9394
class EntitlementClassVisitor extends ClassVisitor {
9495

95-
private static final String ENTITLEMENT_ANNOTATION = "EntitlementInstrumented";
96+
private static final String ENTITLEMENT_ANNOTATION_DESCRIPTOR = Type.getDescriptor(EntitlementInstrumented.class);
9697

9798
private final String className;
9899

@@ -111,7 +112,7 @@ public void visit(int version, int access, String name, String signature, String
111112

112113
@Override
113114
public AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {
114-
if (visible && descriptor.equals(ENTITLEMENT_ANNOTATION)) {
115+
if (visible && descriptor.equals(ENTITLEMENT_ANNOTATION_DESCRIPTOR)) {
115116
isAnnotationPresent = true;
116117
annotationNeeded = false;
117118
}
@@ -177,7 +178,7 @@ public MethodVisitor visitMethod(int access, String name, String descriptor, Str
177178
private void addClassAnnotationIfNeeded() {
178179
if (annotationNeeded) {
179180
// logger.debug("Adding {} annotation", ENTITLEMENT_ANNOTATION);
180-
AnnotationVisitor av = cv.visitAnnotation(ENTITLEMENT_ANNOTATION, true);
181+
AnnotationVisitor av = cv.visitAnnotation(ENTITLEMENT_ANNOTATION_DESCRIPTOR, true);
181182
if (av != null) {
182183
av.visitEnd();
183184
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.entitlement.instrumentation;
11+
12+
import java.lang.annotation.ElementType;
13+
import java.lang.annotation.Retention;
14+
import java.lang.annotation.RetentionPolicy;
15+
import java.lang.annotation.Target;
16+
17+
@Retention(RetentionPolicy.RUNTIME)
18+
@Target(ElementType.TYPE)
19+
public @interface EntitlementInstrumented {
20+
}

0 commit comments

Comments
 (0)