diff --git a/libs/entitlement/asm-provider/src/main/java/org/elasticsearch/entitlement/instrumentation/impl/InstrumenterImpl.java b/libs/entitlement/asm-provider/src/main/java/org/elasticsearch/entitlement/instrumentation/impl/InstrumenterImpl.java index 4d8f0bce655b1..c9b1bb6fe00db 100644 --- a/libs/entitlement/asm-provider/src/main/java/org/elasticsearch/entitlement/instrumentation/impl/InstrumenterImpl.java +++ b/libs/entitlement/asm-provider/src/main/java/org/elasticsearch/entitlement/instrumentation/impl/InstrumenterImpl.java @@ -10,6 +10,7 @@ package org.elasticsearch.entitlement.instrumentation.impl; import org.elasticsearch.entitlement.instrumentation.CheckMethod; +import org.elasticsearch.entitlement.instrumentation.EntitlementInstrumented; import org.elasticsearch.entitlement.instrumentation.Instrumenter; import org.elasticsearch.entitlement.instrumentation.MethodKey; import org.elasticsearch.logging.LogManager; @@ -92,7 +93,7 @@ public byte[] instrumentClass(String className, byte[] classfileBuffer) { class EntitlementClassVisitor extends ClassVisitor { - private static final String ENTITLEMENT_ANNOTATION = "EntitlementInstrumented"; + private static final String ENTITLEMENT_ANNOTATION_DESCRIPTOR = Type.getDescriptor(EntitlementInstrumented.class); private final String className; @@ -111,7 +112,7 @@ public void visit(int version, int access, String name, String signature, String @Override public AnnotationVisitor visitAnnotation(String descriptor, boolean visible) { - if (visible && descriptor.equals(ENTITLEMENT_ANNOTATION)) { + if (visible && descriptor.equals(ENTITLEMENT_ANNOTATION_DESCRIPTOR)) { isAnnotationPresent = true; annotationNeeded = false; } @@ -177,7 +178,7 @@ public MethodVisitor visitMethod(int access, String name, String descriptor, Str private void addClassAnnotationIfNeeded() { if (annotationNeeded) { // logger.debug("Adding {} annotation", ENTITLEMENT_ANNOTATION); - AnnotationVisitor av = cv.visitAnnotation(ENTITLEMENT_ANNOTATION, true); + AnnotationVisitor av = cv.visitAnnotation(ENTITLEMENT_ANNOTATION_DESCRIPTOR, true); if (av != null) { av.visitEnd(); } diff --git a/libs/entitlement/src/main/java/org/elasticsearch/entitlement/instrumentation/EntitlementInstrumented.java b/libs/entitlement/src/main/java/org/elasticsearch/entitlement/instrumentation/EntitlementInstrumented.java new file mode 100644 index 0000000000000..5621f8f6dcaf3 --- /dev/null +++ b/libs/entitlement/src/main/java/org/elasticsearch/entitlement/instrumentation/EntitlementInstrumented.java @@ -0,0 +1,20 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +package org.elasticsearch.entitlement.instrumentation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface EntitlementInstrumented { +}