Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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;
}
Expand Down Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
}