mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
add method getAnnotation
This commit is contained in:
parent
d06899b669
commit
3e207615ac
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2011 - 2017 Volker Berlin (i-net software)
|
Copyright 2011 - 2018 Volker Berlin (i-net software)
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@ -18,6 +18,9 @@ package de.inetsoftware.classparser;
|
|||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import de.inetsoftware.classparser.Attributes.AttributeInfo;
|
import de.inetsoftware.classparser.Attributes.AttributeInfo;
|
||||||
|
|
||||||
@ -42,6 +45,8 @@ public class MethodInfo {
|
|||||||
|
|
||||||
private ClassFile classFile;
|
private ClassFile classFile;
|
||||||
|
|
||||||
|
private Annotations annotations;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the method_info structure
|
* Read the method_info structure
|
||||||
* http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.6
|
* http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.6
|
||||||
@ -152,10 +157,31 @@ public class MethodInfo {
|
|||||||
* Get the annotations with @Retention(RetentionPolicy.CLASS)
|
* Get the annotations with @Retention(RetentionPolicy.CLASS)
|
||||||
* @return the annotations if there any exists else null
|
* @return the annotations if there any exists else null
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public Annotations getRuntimeInvisibleAnnotations() throws IOException {
|
public Annotations getRuntimeInvisibleAnnotations() throws IOException {
|
||||||
AttributeInfo data = attributes.get( "RuntimeInvisibleAnnotations" );
|
if( annotations == null ) {
|
||||||
if( data != null ) {
|
AttributeInfo data = attributes.get( "RuntimeInvisibleAnnotations" );
|
||||||
return new Annotations( data.getDataInputStream(), constantPool );
|
if( data != null ) {
|
||||||
|
annotations = new Annotations( data.getDataInputStream(), constantPool );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return annotations;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a single annotation or null
|
||||||
|
*
|
||||||
|
* @param annotation
|
||||||
|
* the class name of the annotation
|
||||||
|
* @return the value or null if not exists
|
||||||
|
* @throws IOException
|
||||||
|
* if any I/O error occur
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public Map<String, Object> getAnnotation( String annotation ) throws IOException {
|
||||||
|
Annotations annotations = getRuntimeInvisibleAnnotations();
|
||||||
|
if( annotations != null ) {
|
||||||
|
return annotations.get( annotation );
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user