FELIX-2704 : @Property(cardinality=Integer.MAX_Int, ...) causes java.lang.NumberFormatException
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1073041 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java
index 3e4dfe9..c6131f7 100644
--- a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java
+++ b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java
@@ -18,15 +18,9 @@
*/
package org.apache.felix.scrplugin.tags.annotation.defaulttag;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
-import org.apache.felix.scr.annotations.Property;
-import org.apache.felix.scr.annotations.PropertyOption;
-import org.apache.felix.scr.annotations.PropertyUnbounded;
+import org.apache.felix.scr.annotations.*;
import org.apache.felix.scrplugin.Constants;
import org.apache.felix.scrplugin.tags.JavaClassDescription;
import org.apache.felix.scrplugin.tags.JavaField;
@@ -254,7 +248,13 @@
map.put(Constants.PROPERTY_CARDINALITY, "-");
}
} else if (this.annotation.cardinality() != 0) {
- map.put(Constants.PROPERTY_CARDINALITY, String.valueOf(this.annotation.cardinality()));
+ if ( this.annotation.cardinality() == Integer.MAX_VALUE ) {
+ map.put(Constants.PROPERTY_CARDINALITY, "+");
+ } else if ( this.annotation.cardinality() == Integer.MIN_VALUE ) {
+ map.put(Constants.PROPERTY_CARDINALITY, "-");
+ } else {
+ map.put(Constants.PROPERTY_CARDINALITY, String.valueOf(this.annotation.cardinality()));
+ }
}
map.put(Constants.PROPERTY_PRIVATE, String.valueOf(this.annotation.propertyPrivate()));
diff --git a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/annotation/Util.java b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/annotation/Util.java
index a9aa41c..df15404 100644
--- a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/annotation/Util.java
+++ b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/annotation/Util.java
@@ -55,12 +55,16 @@
public static int getIntValue(Annotation annotation, String name, final Class<?> clazz) {
final Object obj = annotation.getNamedParameter(name);
if ( obj != null ) {
- if ( obj instanceof String ) {
- return Integer.valueOf((String)obj);
- } else if ( obj instanceof Number ) {
+ if ( obj instanceof Number ) {
return ((Number)obj).intValue();
}
- return Integer.valueOf(obj.toString());
+ final String value = obj.toString();
+ if ( value.equals("Integer.MAX_VALUE") ) {
+ return Integer.MAX_VALUE;
+ } else if ( value.equals("Integer.MIN_VALUE") ) {
+ return Integer.MIN_VALUE;
+ }
+ return Integer.valueOf(value);
}
try {
return (Integer) clazz.getMethod(name).getDefaultValue();