Skip to content

Adapt instances of AnnotationValue in the annotation processor#131

Merged
dscho merged 1 commit intomasterfrom
annotation-value
Oct 8, 2014
Merged

Adapt instances of AnnotationValue in the annotation processor#131
dscho merged 1 commit intomasterfrom
annotation-value

Conversation

@dscho
Copy link
Contributor

@dscho dscho commented Oct 8, 2014

Kevin Mader reported that certain @interfaces were not handled gracefully
because the annotation processor would encounter AnnotationValue instances
and not know how to handle them.

This fixes #130.

Without these changes, the example provided below yielded the following
exception:

error: java.io.IOException: Cannot handle object of type class com.sun.tools.javac.code.Attribute$Constant
    at org.scijava.annotations.AbstractIndexWriter.writeObject(AbstractIndexWriter.java:252)
    at org.scijava.annotations.AbstractIndexWriter.writeArray(AbstractIndexWriter.java:306)
    at org.scijava.annotations.AbstractIndexWriter.writeObject(AbstractIndexWriter.java:243)
    at org.scijava.annotations.AbstractIndexWriter.writeMap(AbstractIndexWriter.java:288)
    at org.scijava.annotations.AbstractIndexWriter.writeObject(AbstractIndexWriter.java:249)
    at org.scijava.annotations.AbstractIndexWriter.writeMap(AbstractIndexWriter.java:288)
    at org.scijava.annotations.AbstractIndexWriter.writeObject(AbstractIndexWriter.java:249)
    at org.scijava.annotations.AbstractIndexWriter.write(AbstractIndexWriter.java:99)
    at org.scijava.annotations.AnnotationProcessor.process(AnnotationProcessor.java:91)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:627)
    ...

-- snip BlockIdentity.java --
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.scijava.annotations.Indexable;

@target(ElementType.TYPE)
@retention(RetentionPolicy.RUNTIME)
@indexable
public @interface BlockIdentity {
String blockName();
String desc() default "";
String[] inputNames();
String[] outputNames();
}
-- snap --

-- snip Test.java --
@Blockidentity(blockName = "GrowRegionsBlock",
inputNames= {"labeled image", "mask image"},
outputNames= {"filled labels", "filled neighborhood"})
public class Test {}
-- snap --

Signed-off-by: Johannes Schindelin johannes.schindelin@gmx.de

Kevin Mader reported that certain @interfaces were not handled gracefully
because the annotation processor would encounter AnnotationValue instances
and not know how to handle them.

This fixes #130.

Without these changes, the example provided below yielded the following
exception:

	error: java.io.IOException: Cannot handle object of type class com.sun.tools.javac.code.Attribute$Constant
		at org.scijava.annotations.AbstractIndexWriter.writeObject(AbstractIndexWriter.java:252)
		at org.scijava.annotations.AbstractIndexWriter.writeArray(AbstractIndexWriter.java:306)
		at org.scijava.annotations.AbstractIndexWriter.writeObject(AbstractIndexWriter.java:243)
		at org.scijava.annotations.AbstractIndexWriter.writeMap(AbstractIndexWriter.java:288)
		at org.scijava.annotations.AbstractIndexWriter.writeObject(AbstractIndexWriter.java:249)
		at org.scijava.annotations.AbstractIndexWriter.writeMap(AbstractIndexWriter.java:288)
		at org.scijava.annotations.AbstractIndexWriter.writeObject(AbstractIndexWriter.java:249)
		at org.scijava.annotations.AbstractIndexWriter.write(AbstractIndexWriter.java:99)
		at org.scijava.annotations.AnnotationProcessor.process(AnnotationProcessor.java:91)
		at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:627)
		...

-- snip BlockIdentity.java --
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.scijava.annotations.Indexable;

@target(ElementType.TYPE)
@retention(RetentionPolicy.RUNTIME)
@indexable
public @interface BlockIdentity {
    String blockName();
    String desc() default "";
    String[] inputNames();
    String[] outputNames();
}
-- snap --

-- snip Test.java --
@Blockidentity(blockName = "GrowRegionsBlock",
            inputNames= {"labeled image", "mask image"},
            outputNames= {"filled labels", "filled neighborhood"})
public class Test {}
-- snap --

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit that referenced this pull request Oct 8, 2014
Adapt instances of AnnotationValue in the annotation processor
@dscho dscho merged commit 8fa230a into master Oct 8, 2014
@dscho dscho deleted the annotation-value branch October 8, 2014 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Annotation fails when using array of constant strings

1 participant