You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by mc...@apache.org on 2012/06/15 15:28:02 UTC
svn commit: r1350613 [9/14] - in
/felix/trunk/bundleplugin/src/main/java/aQute: bnd/annotation/
bnd/annotation/component/ bnd/annotation/metatype/ bnd/build/
bnd/compatibility/ bnd/component/ bnd/differ/ bnd/help/ bnd/make/
bnd/make/calltree/ bnd/make/...
Modified: felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Clazz.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Clazz.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Clazz.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Clazz.java Fri Jun 15 13:27:53 2012
@@ -87,10 +87,8 @@ public class Clazz {
}
- public final static EnumSet<QUERY> HAS_ARGUMENT = EnumSet.of(QUERY.IMPLEMENTS,
- QUERY.EXTENDS, QUERY.IMPORTS,
- QUERY.NAMED, QUERY.VERSION,
- QUERY.ANNOTATED);
+ public final static EnumSet<QUERY> HAS_ARGUMENT = EnumSet.of(QUERY.IMPLEMENTS, QUERY.EXTENDS, QUERY.IMPORTS,
+ QUERY.NAMED, QUERY.VERSION, QUERY.ANNOTATED);
/**
* <pre>
@@ -106,29 +104,29 @@ public class Clazz {
*
* @param mod
*/
- final static int ACC_PUBLIC = 0x0001; // Declared
+ final static int ACC_PUBLIC = 0x0001; // Declared
// public;
// may
// be
// accessed
// from outside its package.
- final static int ACC_FINAL = 0x0010; // Declared
+ final static int ACC_FINAL = 0x0010; // Declared
// final;
// no
// subclasses
// allowed.
- final static int ACC_SUPER = 0x0020; // Treat
+ final static int ACC_SUPER = 0x0020; // Treat
// superclass
// methods
// specially when invoked by the
// invokespecial instruction.
- final static int ACC_INTERFACE = 0x0200; // Is
+ final static int ACC_INTERFACE = 0x0200; // Is
// an
// interface,
// not
// a
// classs
- final static int ACC_ABSTRACT = 0x0400; // Declared
+ final static int ACC_ABSTRACT = 0x0400; // Declared
// a thing not in the source code
final static int ACC_SYNTHETIC = 0x1000;
@@ -303,7 +301,7 @@ public class Clazz {
}
final static byte SkipTable[] = { //
- 0, // 0 non existent
+ 0, // 0 non existent
-1, // 1 CONSTANT_utf8 UTF 8, handled in
// method
-1, // 2
@@ -371,7 +369,8 @@ public class Clazz {
InputStream in = resource.openInputStream();
try {
return parseClassFile(in, cd);
- } finally {
+ }
+ finally {
in.close();
}
}
@@ -381,7 +380,8 @@ public class Clazz {
try {
this.cd = cd;
return parseClassFile(din);
- } finally {
+ }
+ finally {
cd = null;
din.close();
}
@@ -409,59 +409,59 @@ public class Clazz {
process: for (int poolIndex = 1; poolIndex < count; poolIndex++) {
byte tag = in.readByte();
switch (tag) {
- case 0:
- break process;
- case 1:
- constantUtf8(in, poolIndex);
- break;
-
- case 3:
- constantInteger(in, poolIndex);
- break;
-
- case 4:
- constantFloat(in, poolIndex);
- break;
-
- // For some insane optimization reason are
- // the long and the double two entries in the
- // constant pool. See 4.4.5
- case 5:
- constantLong(in, poolIndex);
- poolIndex++;
- break;
-
- case 6:
- constantDouble(in, poolIndex);
- poolIndex++;
- break;
-
- case 7:
- constantClass(in, poolIndex);
- break;
-
- case 8:
- constantString(in, poolIndex);
- break;
-
- case 10: // Method ref
- case 11: // Interface Method ref
- methodRef(in, poolIndex);
- break;
-
- // Name and Type
- case 12:
- nameAndType(in, poolIndex, tag);
- break;
-
- // We get the skip count for each record type
- // from the SkipTable. This will also automatically
- // abort when
- default:
- if (tag == 2)
- throw new IOException("Invalid tag " + tag);
- in.skipBytes(SkipTable[tag]);
- break;
+ case 0 :
+ break process;
+ case 1 :
+ constantUtf8(in, poolIndex);
+ break;
+
+ case 3 :
+ constantInteger(in, poolIndex);
+ break;
+
+ case 4 :
+ constantFloat(in, poolIndex);
+ break;
+
+ // For some insane optimization reason are
+ // the long and the double two entries in the
+ // constant pool. See 4.4.5
+ case 5 :
+ constantLong(in, poolIndex);
+ poolIndex++;
+ break;
+
+ case 6 :
+ constantDouble(in, poolIndex);
+ poolIndex++;
+ break;
+
+ case 7 :
+ constantClass(in, poolIndex);
+ break;
+
+ case 8 :
+ constantString(in, poolIndex);
+ break;
+
+ case 10 : // Method ref
+ case 11 : // Interface Method ref
+ methodRef(in, poolIndex);
+ break;
+
+ // Name and Type
+ case 12 :
+ nameAndType(in, poolIndex, tag);
+ break;
+
+ // We get the skip count for each record type
+ // from the SkipTable. This will also automatically
+ // abort when
+ default :
+ if (tag == 2)
+ throw new IOException("Invalid tag " + tag);
+ in.skipBytes(SkipTable[tag]);
+ break;
}
}
@@ -499,8 +499,7 @@ public class Clazz {
if (interfacesCount > 0) {
interfaces = new TypeRef[interfacesCount];
for (int i = 0; i < interfacesCount; i++)
- interfaces[i] = analyzer.getTypeRef((String) pool[intPool[in
- .readUnsignedShort()]]);
+ interfaces[i] = analyzer.getTypeRef((String) pool[intPool[in.readUnsignedShort()]]);
if (cd != null)
cd.implementsInterfaces(interfaces);
}
@@ -526,8 +525,7 @@ public class Clazz {
crawl = true;
}
if (cd != null)
- cd.field(last = new FieldDef(access_flags, name, pool[descriptor_index]
- .toString()));
+ cd.field(last = new FieldDef(access_flags, name, pool[descriptor_index].toString()));
descriptors.add(Integer.valueOf(descriptor_index));
doAttributes(in, ElementType.FIELD, false);
}
@@ -539,24 +537,21 @@ public class Clazz {
// can do this efficiently
//
if (crawl) {
- forName = findMethodReference("java/lang/Class", "forName",
- "(Ljava/lang/String;)Ljava/lang/Class;");
- class$ = findMethodReference(className.getBinary(), "class$",
- "(Ljava/lang/String;)Ljava/lang/Class;");
- } else if (major == 48 ) {
- forName = findMethodReference("java/lang/Class", "forName",
- "(Ljava/lang/String;)Ljava/lang/Class;");
+ forName = findMethodReference("java/lang/Class", "forName", "(Ljava/lang/String;)Ljava/lang/Class;");
+ class$ = findMethodReference(className.getBinary(), "class$", "(Ljava/lang/String;)Ljava/lang/Class;");
+ } else if (major == 48) {
+ forName = findMethodReference("java/lang/Class", "forName", "(Ljava/lang/String;)Ljava/lang/Class;");
if (forName > 0) {
crawl = true;
class$ = findMethodReference(className.getBinary(), "class$",
"(Ljava/lang/String;)Ljava/lang/Class;");
}
}
-
+
// There are some serious changes in the
// class file format. So we do not do any crawling
// it has also become less important
- if ( major >= JAVA.OpenJDK7.major )
+ if (major >= JAVA.OpenJDK7.major)
crawl = false;
//
@@ -614,7 +609,8 @@ public class Clazz {
Set<TypeRef> xref = this.xref;
reset();
return xref;
- } finally {
+ }
+ finally {
if (cd != null)
cd.classEnd();
}
@@ -633,8 +629,7 @@ public class Clazz {
pool[poolIndex] = intPool[poolIndex];
}
- protected void pool(Object[] pool, int[] intPool) {
- }
+ protected void pool(Object[] pool, int[] intPool) {}
/**
* @param in
@@ -762,8 +757,7 @@ public class Clazz {
* The stream
* @throws Exception
*/
- private void doAttributes(DataInputStream in, ElementType member, boolean crawl)
- throws Exception {
+ private void doAttributes(DataInputStream in, ElementType member, boolean crawl) throws Exception {
int attributesCount = in.readUnsignedShort();
for (int j = 0; j < attributesCount; j++) {
// skip name CONSTANT_Utf8 pointer
@@ -778,8 +772,7 @@ public class Clazz {
* the data stream
* @throws Exception
*/
- private void doAttribute(DataInputStream in, ElementType member, boolean crawl)
- throws Exception {
+ private void doAttribute(DataInputStream in, ElementType member, boolean crawl) throws Exception {
int attribute_name_index = in.readUnsignedShort();
String attributeName = (String) pool[attribute_name_index];
long attribute_length = in.readInt();
@@ -825,7 +818,6 @@ public class Clazz {
* }
* </pre>
*
- *
* @param in
* @throws IOException
*/
@@ -996,83 +988,84 @@ public class Clazz {
while (bb.remaining() > 0) {
int instruction = 0xFF & bb.get();
switch (instruction) {
- case OpCodes.ldc:
- lastReference = 0xFF & bb.get();
- break;
-
- case OpCodes.ldc_w:
- lastReference = 0xFFFF & bb.getShort();
- break;
-
- case OpCodes.invokespecial: {
- int mref = 0xFFFF & bb.getShort();
- if (cd != null)
- getMethodDef(0, mref);
- break;
- }
-
- case OpCodes.invokevirtual: {
- int mref = 0xFFFF & bb.getShort();
- if (cd != null)
- getMethodDef(0, mref);
- break;
- }
+ case OpCodes.ldc :
+ lastReference = 0xFF & bb.get();
+ break;
+
+ case OpCodes.ldc_w :
+ lastReference = 0xFFFF & bb.getShort();
+ break;
+
+ case OpCodes.invokespecial : {
+ int mref = 0xFFFF & bb.getShort();
+ if (cd != null)
+ getMethodDef(0, mref);
+ break;
+ }
- case OpCodes.invokeinterface: {
- int mref = 0xFFFF & bb.getShort();
- if (cd != null)
- getMethodDef(0, mref);
- break;
- }
+ case OpCodes.invokevirtual : {
+ int mref = 0xFFFF & bb.getShort();
+ if (cd != null)
+ getMethodDef(0, mref);
+ break;
+ }
- case OpCodes.invokestatic: {
- int methodref = 0xFFFF & bb.getShort();
- if (cd != null)
- getMethodDef(0, methodref);
+ case OpCodes.invokeinterface : {
+ int mref = 0xFFFF & bb.getShort();
+ if (cd != null)
+ getMethodDef(0, mref);
+ break;
+ }
- if ((methodref == forName || methodref == class$) && lastReference != -1
- && pool[intPool[lastReference]] instanceof String) {
- String fqn = (String) pool[intPool[lastReference]];
- if (!fqn.equals("class") && fqn.indexOf('.') > 0) {
- TypeRef clazz = analyzer.getTypeRefFromFQN(fqn);
- referTo(clazz);
+ case OpCodes.invokestatic : {
+ int methodref = 0xFFFF & bb.getShort();
+ if (cd != null)
+ getMethodDef(0, methodref);
+
+ if ((methodref == forName || methodref == class$) && lastReference != -1
+ && pool[intPool[lastReference]] instanceof String) {
+ String fqn = (String) pool[intPool[lastReference]];
+ if (!fqn.equals("class") && fqn.indexOf('.') > 0) {
+ TypeRef clazz = analyzer.getTypeRefFromFQN(fqn);
+ referTo(clazz);
+ }
+ lastReference = -1;
}
- lastReference = -1;
+ break;
}
- break;
- }
- case OpCodes.tableswitch:
- // Skip to place divisible by 4
- while ((bb.position() & 0x3) != 0)
- bb.get();
- /* int deflt = */
- bb.getInt();
- int low = bb.getInt();
- int high = bb.getInt();
- try {
- bb.position(bb.position() + (high - low + 1) * 4);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- lastReference = -1;
- break;
+ case OpCodes.tableswitch :
+ // Skip to place divisible by 4
+ while ((bb.position() & 0x3) != 0)
+ bb.get();
+ /* int deflt = */
+ bb.getInt();
+ int low = bb.getInt();
+ int high = bb.getInt();
+ try {
+ bb.position(bb.position() + (high - low + 1) * 4);
+ }
+ catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ lastReference = -1;
+ break;
- case OpCodes.lookupswitch:
- // Skip to place divisible by 4
- while ((bb.position() & 0x3) != 0)
- bb.get();
- /* deflt = */
- bb.getInt();
- int npairs = bb.getInt();
- bb.position(bb.position() + npairs * 8);
- lastReference = -1;
- break;
+ case OpCodes.lookupswitch :
+ // Skip to place divisible by 4
+ while ((bb.position() & 0x3) != 0)
+ bb.get();
+ /* deflt = */
+ bb.getInt();
+ int npairs = bb.getInt();
+ bb.position(bb.position() + npairs * 8);
+ lastReference = -1;
+ break;
- default:
- lastReference = -1;
- bb.position(bb.position() + OpCodes.OFFSETS[instruction]);
+ default :
+ lastReference = -1;
+ bb.position(bb.position() + OpCodes.OFFSETS[instruction]);
}
}
}
@@ -1082,8 +1075,8 @@ public class Clazz {
this.sourceFile = pool[sourcefile_index].toString();
}
- private void doParameterAnnotations(DataInputStream in, ElementType member,
- RetentionPolicy policy) throws IOException {
+ private void doParameterAnnotations(DataInputStream in, ElementType member, RetentionPolicy policy)
+ throws IOException {
int num_parameters = in.readUnsignedByte();
for (int p = 0; p < num_parameters; p++) {
if (cd != null)
@@ -1092,8 +1085,7 @@ public class Clazz {
}
}
- private void doAnnotations(DataInputStream in, ElementType member, RetentionPolicy policy)
- throws IOException {
+ private void doAnnotations(DataInputStream in, ElementType member, RetentionPolicy policy) throws IOException {
int num_annotations = in.readUnsignedShort(); // # of annotations
for (int a = 0; a < num_annotations; a++) {
if (cd == null)
@@ -1105,8 +1097,8 @@ public class Clazz {
}
}
- private Annotation doAnnotation(DataInputStream in, ElementType member, RetentionPolicy policy,
- boolean collect) throws IOException {
+ private Annotation doAnnotation(DataInputStream in, ElementType member, RetentionPolicy policy, boolean collect)
+ throws IOException {
int type_index = in.readUnsignedShort();
if (annotations == null)
annotations = new HashSet<TypeRef>();
@@ -1122,14 +1114,14 @@ public class Clazz {
}
TypeRef name = analyzer.getTypeRef((String) pool[type_index]);
int num_element_value_pairs = in.readUnsignedShort();
- Map<String, Object> elements = null;
+ Map<String,Object> elements = null;
for (int v = 0; v < num_element_value_pairs; v++) {
int element_name_index = in.readUnsignedShort();
String element = (String) pool[element_name_index];
Object value = doElementValue(in, member, policy, collect);
if (collect) {
if (elements == null)
- elements = new LinkedHashMap<String, Object>();
+ elements = new LinkedHashMap<String,Object>();
elements.put(element, value);
}
}
@@ -1139,56 +1131,54 @@ public class Clazz {
return null;
}
- private Object doElementValue(DataInputStream in, ElementType member, RetentionPolicy policy,
- boolean collect) throws IOException {
+ private Object doElementValue(DataInputStream in, ElementType member, RetentionPolicy policy, boolean collect)
+ throws IOException {
char tag = (char) in.readUnsignedByte();
switch (tag) {
- case 'B': // Byte
- case 'C': // Character
- case 'I': // Integer
- case 'S': // Short
- int const_value_index = in.readUnsignedShort();
- return intPool[const_value_index];
-
- case 'D': // Double
- case 'F': // Float
- case 's': // String
- case 'J': // Long
- const_value_index = in.readUnsignedShort();
- return pool[const_value_index];
-
- case 'Z': // Boolean
- const_value_index = in.readUnsignedShort();
- return pool[const_value_index] == null || pool[const_value_index].equals(0) ? false
- : true;
-
- case 'e': // enum constant
- int type_name_index = in.readUnsignedShort();
- if (policy == RetentionPolicy.RUNTIME)
- descriptors.add(Integer.valueOf(type_name_index));
- int const_name_index = in.readUnsignedShort();
- return pool[const_name_index];
-
- case 'c': // Class
- int class_info_index = in.readUnsignedShort();
- if (policy == RetentionPolicy.RUNTIME)
- descriptors.add(Integer.valueOf(class_info_index));
- return pool[class_info_index];
-
- case '@': // Annotation type
- return doAnnotation(in, member, policy, collect);
-
- case '[': // Array
- int num_values = in.readUnsignedShort();
- Object[] result = new Object[num_values];
- for (int i = 0; i < num_values; i++) {
- result[i] = doElementValue(in, member, policy, collect);
- }
- return result;
-
- default:
- throw new IllegalArgumentException("Invalid value for Annotation ElementValue tag "
- + tag);
+ case 'B' : // Byte
+ case 'C' : // Character
+ case 'I' : // Integer
+ case 'S' : // Short
+ int const_value_index = in.readUnsignedShort();
+ return intPool[const_value_index];
+
+ case 'D' : // Double
+ case 'F' : // Float
+ case 's' : // String
+ case 'J' : // Long
+ const_value_index = in.readUnsignedShort();
+ return pool[const_value_index];
+
+ case 'Z' : // Boolean
+ const_value_index = in.readUnsignedShort();
+ return pool[const_value_index] == null || pool[const_value_index].equals(0) ? false : true;
+
+ case 'e' : // enum constant
+ int type_name_index = in.readUnsignedShort();
+ if (policy == RetentionPolicy.RUNTIME)
+ descriptors.add(Integer.valueOf(type_name_index));
+ int const_name_index = in.readUnsignedShort();
+ return pool[const_name_index];
+
+ case 'c' : // Class
+ int class_info_index = in.readUnsignedShort();
+ if (policy == RetentionPolicy.RUNTIME)
+ descriptors.add(Integer.valueOf(class_info_index));
+ return pool[class_info_index];
+
+ case '@' : // Annotation type
+ return doAnnotation(in, member, policy, collect);
+
+ case '[' : // Array
+ int num_values = in.readUnsignedShort();
+ Object[] result = new Object[num_values];
+ for (int i = 0; i < num_values; i++) {
+ result[i] = doElementValue(in, member, policy, collect);
+ }
+ return result;
+
+ default :
+ throw new IllegalArgumentException("Invalid value for Annotation ElementValue tag " + tag);
}
}
@@ -1213,9 +1203,7 @@ public class Clazz {
/**
* This method parses a descriptor and adds the package of the descriptor to
- * the referenced packages.
- *
- * The syntax of the descriptor is:
+ * the referenced packages. The syntax of the descriptor is:
*
* <pre>
* descriptor ::= ( '(' reference * ')' )? reference
@@ -1363,17 +1351,12 @@ public class Clazz {
}
/**
- * .class construct for different compilers
- *
- * sun 1.1 Detect static variable class$com$acme$MyClass 1.2 " 1.3 " 1.4 "
- * 1.5 ldc_w (class) 1.6 "
- *
- * eclipse 1.1 class$0, ldc (string), invokestatic Class.forName 1.2 " 1.3 "
- * 1.5 ldc (class) 1.6 "
- *
- * 1.5 and later is not an issue, sun pre 1.5 is easy to detect the static
- * variable that decodes the class name. For eclipse, the class$0 gives away
- * we have a reference encoded in a string.
+ * .class construct for different compilers sun 1.1 Detect static variable
+ * class$com$acme$MyClass 1.2 " 1.3 " 1.4 " 1.5 ldc_w (class) 1.6 " eclipse
+ * 1.1 class$0, ldc (string), invokestatic Class.forName 1.2 " 1.3 " 1.5 ldc
+ * (class) 1.6 " 1.5 and later is not an issue, sun pre 1.5 is easy to
+ * detect the static variable that decodes the class name. For eclipse, the
+ * class$0 gives away we have a reference encoded in a string.
* compilerversions/compilerversions.jar contains test versions of all
* versions/compilers.
*/
@@ -1388,65 +1371,65 @@ public class Clazz {
public boolean is(QUERY query, Instruction instr, Analyzer analyzer) throws Exception {
switch (query) {
- case ANY:
- return true;
-
- case NAMED:
- if (instr.matches(getClassName().getDottedOnly()))
- return !instr.isNegated();
- return false;
+ case ANY :
+ return true;
- case VERSION:
- String v = major + "." + minor;
- if (instr.matches(v))
- return !instr.isNegated();
- return false;
-
- case IMPLEMENTS:
- for (int i = 0; interfaces != null && i < interfaces.length; i++) {
- if (instr.matches(interfaces[i].getDottedOnly()))
+ case NAMED :
+ if (instr.matches(getClassName().getDottedOnly()))
return !instr.isNegated();
- }
- break;
+ return false;
- case EXTENDS:
- if (zuper == null)
+ case VERSION :
+ String v = major + "." + minor;
+ if (instr.matches(v))
+ return !instr.isNegated();
return false;
- if (instr.matches(zuper.getDottedOnly()))
- return !instr.isNegated();
- break;
+ case IMPLEMENTS :
+ for (int i = 0; interfaces != null && i < interfaces.length; i++) {
+ if (instr.matches(interfaces[i].getDottedOnly()))
+ return !instr.isNegated();
+ }
+ break;
- case PUBLIC:
- return Modifier.isPublic(accessx);
+ case EXTENDS :
+ if (zuper == null)
+ return false;
- case CONCRETE:
- return !Modifier.isAbstract(accessx);
+ if (instr.matches(zuper.getDottedOnly()))
+ return !instr.isNegated();
+ break;
- case ANNOTATED:
- if (annotations == null)
- return false;
+ case PUBLIC :
+ return Modifier.isPublic(accessx);
- for (TypeRef annotation : annotations) {
- if (instr.matches(annotation.getFQN()))
- return !instr.isNegated();
- }
+ case CONCRETE :
+ return !Modifier.isAbstract(accessx);
- return false;
+ case ANNOTATED :
+ if (annotations == null)
+ return false;
+
+ for (TypeRef annotation : annotations) {
+ if (instr.matches(annotation.getFQN()))
+ return !instr.isNegated();
+ }
- case RUNTIMEANNOTATIONS:
- return hasClassAnnotations;
- case CLASSANNOTATIONS:
- return hasClassAnnotations;
-
- case ABSTRACT:
- return Modifier.isAbstract(accessx);
-
- case IMPORTS:
- for (PackageRef imp : imports) {
- if (instr.matches(imp.getFQN()))
- return !instr.isNegated();
- }
+ return false;
+
+ case RUNTIMEANNOTATIONS :
+ return hasClassAnnotations;
+ case CLASSANNOTATIONS :
+ return hasClassAnnotations;
+
+ case ABSTRACT :
+ return Modifier.isAbstract(accessx);
+
+ case IMPORTS :
+ for (PackageRef imp : imports) {
+ if (instr.matches(imp.getFQN()))
+ return !instr.isNegated();
+ }
}
if (zuper == null)
@@ -1465,12 +1448,11 @@ public class Clazz {
/**
* Called when crawling the byte code and a method reference is found
- *
*/
void getMethodDef(int access, int methodRefPoolIndex) {
- if ( methodRefPoolIndex == 0)
+ if (methodRefPoolIndex == 0)
return;
-
+
Object o = pool[methodRefPoolIndex];
if (o != null && o instanceof Assoc) {
Assoc assoc = (Assoc) o;
@@ -1493,8 +1475,7 @@ public class Clazz {
throw new IllegalArgumentException(
"Invalid class file (or parsing is wrong), Assoc is not method ref! (10)");
} else
- throw new IllegalArgumentException(
- "Invalid class file (or parsing is wrong), Not an assoc at a method ref");
+ throw new IllegalArgumentException("Invalid class file (or parsing is wrong), Not an assoc at a method ref");
}
public boolean isPublic() {
@@ -1519,26 +1500,26 @@ public class Clazz {
return string.substring(1, string.length() - 1).replace('/', '.');
switch (string.charAt(0)) {
- case 'V':
- return "void";
- case 'B':
- return "byte";
- case 'C':
- return "char";
- case 'I':
- return "int";
- case 'S':
- return "short";
- case 'D':
- return "double";
- case 'F':
- return "float";
- case 'J':
- return "long";
- case 'Z':
- return "boolean";
- case '[': // Array
- return objectDescriptorToFQN(string.substring(1)) + "[]";
+ case 'V' :
+ return "void";
+ case 'B' :
+ return "byte";
+ case 'C' :
+ return "char";
+ case 'I' :
+ return "int";
+ case 'S' :
+ return "short";
+ case 'D' :
+ return "double";
+ case 'F' :
+ return "float";
+ case 'J' :
+ return "long";
+ case 'Z' :
+ return "boolean";
+ case '[' : // Array
+ return objectDescriptorToFQN(string.substring(1)) + "[]";
}
throw new IllegalArgumentException("Invalid type character in descriptor " + string);
}
Modified: felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/CombinedResource.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/CombinedResource.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/CombinedResource.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/CombinedResource.java Fri Jun 15 13:27:53 2012
@@ -14,16 +14,15 @@
* limitations under the License.
*/
-
package aQute.lib.osgi;
import java.io.*;
import java.util.*;
public class CombinedResource extends WriteResource {
- final List<Resource> resources = new ArrayList<Resource>();
- long lastModified = 0;
-
+ final List<Resource> resources = new ArrayList<Resource>();
+ long lastModified = 0;
+
@Override
public void write(final OutputStream out) throws IOException, Exception {
OutputStream unclosable = new FilterOutputStream(out) {
@@ -31,7 +30,7 @@ public class CombinedResource extends Wr
// Ignore
}
};
- for ( Resource r : resources ) {
+ for (Resource r : resources) {
r.write(unclosable);
unclosable.flush();
}
@@ -47,5 +46,4 @@ public class CombinedResource extends Wr
resources.add(r);
}
-
}
Modified: felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/CommandResource.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/CommandResource.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/CommandResource.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/CommandResource.java Fri Jun 15 13:27:53 2012
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-
package aQute.lib.osgi;
import java.io.*;
@@ -22,10 +21,10 @@ import java.io.*;
import aQute.libg.command.*;
public class CommandResource extends WriteResource {
- final long lastModified;
- final Builder domain;
- final String command;
-
+ final long lastModified;
+ final Builder domain;
+ final String command;
+
public CommandResource(String command, Builder domain, long lastModified) {
this.lastModified = lastModified;
this.domain = domain;
@@ -38,25 +37,26 @@ public class CommandResource extends Wri
StringBuilder stdout = new StringBuilder();
try {
domain.trace("executing command %s", command);
- Command cmd = new Command("sh -l");
+ Command cmd = new Command("sh");
cmd.inherit();
String oldpath = cmd.var("PATH");
-
+
String path = domain.getProperty("-PATH");
if (path != null) {
- path = path.replaceAll("\\s*,\\s*",File.pathSeparator);
+ path = path.replaceAll("\\s*,\\s*", File.pathSeparator);
path = path.replaceAll("\\$\\{@\\}", oldpath);
cmd.var("PATH", path);
domain.trace("PATH: %s", path);
}
OutputStreamWriter osw = new OutputStreamWriter(out);
- int result = cmd.execute(command,stdout, errors);
+ int result = cmd.execute(command, stdout, errors);
osw.append(stdout);
osw.flush();
- if ( result != 0) {
+ if (result != 0) {
domain.error("executing command failed %s %s", command, stdout + "\n" + errors);
}
- } catch( Exception e) {
+ }
+ catch (Exception e) {
domain.error("executing command failed %s %s", command, e.getMessage());
}
}
Modified: felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Constants.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Constants.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Constants.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Constants.java Fri Jun 15 13:27:53 2012
@@ -12,294 +12,293 @@ public interface Constants {
* @syntax Bundle-ActivationPolicy ::= policy ( â;â directive )* policy ::=
* âlazyâ
*/
- String BND_ADDXMLTOTEST = "Bnd-AddXMLToTest";
- String BUNDLE_ACTIVATIONPOLICY = "Bundle-ActivationPolicy";
- String BUNDLE_ACTIVATOR = "Bundle-Activator";
- String BUNDLE_BLUEPRINT = "Bundle-Copyright";
- String BUNDLE_CATEGORY = "Bundle-Category";
- String BUNDLE_CLASSPATH = "Bundle-ClassPath";
- String BUNDLE_CONTACTADDRESS = "Bundle-ContactAddress";
- String BUNDLE_COPYRIGHT = "Bundle-Copyright";
- String BUNDLE_DESCRIPTION = "Bundle-Description";
- String BUNDLE_DOCURL = "Bundle-DocURL";
- String BUNDLE_ICON = "Bundle-Icon";
- String BUNDLE_LICENSE = "Bundle-License";
- String BUNDLE_LOCALIZATION = "Bundle-Localization";
- String BUNDLE_MANIFESTVERSION = "Bundle-ManifestVersion";
- String BUNDLE_NAME = "Bundle-Name";
- String BUNDLE_NATIVECODE = "Bundle-NativeCode";
- String BUNDLE_REQUIREDEXECUTIONENVIRONMENT = "Bundle-RequiredExecutionEnvironment";
- String BUNDLE_SYMBOLICNAME = "Bundle-SymbolicName";
- String BUNDLE_UPDATELOCATION = "Bundle-UpdateLocation";
- String BUNDLE_VENDOR = "Bundle-Vendor";
- String BUNDLE_VERSION = "Bundle-Version";
- String DYNAMICIMPORT_PACKAGE = "DynamicImport-Package";
- String EXPORT_PACKAGE = "Export-Package";
- String EXPORT_SERVICE = "Export-Service";
- String FRAGMENT_HOST = "Fragment-Host";
- String IMPORT_PACKAGE = "Import-Package";
- String IMPORT_SERVICE = "Import-Service";
- String PROVIDE_CAPABILITY = "Provide-Capability";
- String REQUIRE_BUNDLE = "Require-Bundle";
- String REQUIRE_CAPABILITY = "Require-Capability";
- String SERVICE_COMPONENT = "Service-Component";
-
- String PRIVATE_PACKAGE = "Private-Package";
- String IGNORE_PACKAGE = "Ignore-Package";
- String INCLUDE_RESOURCE = "Include-Resource";
- String CONDITIONAL_PACKAGE = "Conditional-Package";
- String BND_LASTMODIFIED = "Bnd-LastModified";
- String CREATED_BY = "Created-By";
- String TOOL = "Tool";
- String TESTCASES = "Test-Cases";
- String SIGNATURE_TEST = "-signaturetest";
-
- String headers[] = {
- BUNDLE_ACTIVATOR, BUNDLE_CONTACTADDRESS, BUNDLE_COPYRIGHT, BUNDLE_DESCRIPTION,
- BUNDLE_DOCURL, BUNDLE_LOCALIZATION, BUNDLE_NATIVECODE, BUNDLE_VENDOR, BUNDLE_VERSION,
- BUNDLE_LICENSE, BUNDLE_CLASSPATH, SERVICE_COMPONENT, EXPORT_PACKAGE, IMPORT_PACKAGE,
- BUNDLE_LOCALIZATION, BUNDLE_MANIFESTVERSION, BUNDLE_NAME, BUNDLE_NATIVECODE,
- BUNDLE_REQUIREDEXECUTIONENVIRONMENT, BUNDLE_SYMBOLICNAME, BUNDLE_VERSION,
- FRAGMENT_HOST, PRIVATE_PACKAGE, IGNORE_PACKAGE, INCLUDE_RESOURCE, REQUIRE_BUNDLE,
- IMPORT_SERVICE, EXPORT_SERVICE, CONDITIONAL_PACKAGE, BND_LASTMODIFIED, TESTCASES,
- SIGNATURE_TEST, REQUIRE_CAPABILITY, PROVIDE_CAPABILITY };
-
- String BUILDPATH = "-buildpath";
- String BUILDPACKAGES = "-buildpackages";
- String BUMPPOLICY = "-bumppolicy";
- String CONDUIT = "-conduit";
- String COMPILER_SOURCE = "-source";
- String COMPILER_TARGET = "-target";
- String DEPENDSON = "-dependson";
- String DEPLOY = "-deploy";
- String DEPLOYREPO = "-deployrepo";
- String DIGESTS = "-digests";
- String DSANNOTATIONS = "-dsannotations";
- String DONOTCOPY = "-donotcopy";
- String DEBUG = "-debug";
- String EXPORT_CONTENTS = "-exportcontents";
- String FAIL_OK = "-failok";
- String INCLUDE = "-include";
- String INCLUDERESOURCE = "-includeresource";
- String MAKE = "-make";
- String METATYPE = "-metatype";
- String MANIFEST = "-manifest";
- String SAVEMANIFEST = "-savemanifest";
- String NAMESECTION = "-namesection";
- String NODEFAULTVERSION = "-nodefaultversion";
- String NOEXTRAHEADERS = "-noextraheaders";
- String NOMANIFEST = "-nomanifest";
- String NOUSES = "-nouses";
+ String BND_ADDXMLTOTEST = "Bnd-AddXMLToTest";
+ String BUNDLE_ACTIVATIONPOLICY = "Bundle-ActivationPolicy";
+ String BUNDLE_ACTIVATOR = "Bundle-Activator";
+ String BUNDLE_BLUEPRINT = "Bundle-Copyright";
+ String BUNDLE_CATEGORY = "Bundle-Category";
+ String BUNDLE_CLASSPATH = "Bundle-ClassPath";
+ String BUNDLE_CONTACTADDRESS = "Bundle-ContactAddress";
+ String BUNDLE_COPYRIGHT = "Bundle-Copyright";
+ String BUNDLE_DESCRIPTION = "Bundle-Description";
+ String BUNDLE_DOCURL = "Bundle-DocURL";
+ String BUNDLE_ICON = "Bundle-Icon";
+ String BUNDLE_LICENSE = "Bundle-License";
+ String BUNDLE_LOCALIZATION = "Bundle-Localization";
+ String BUNDLE_MANIFESTVERSION = "Bundle-ManifestVersion";
+ String BUNDLE_NAME = "Bundle-Name";
+ String BUNDLE_NATIVECODE = "Bundle-NativeCode";
+ String BUNDLE_REQUIREDEXECUTIONENVIRONMENT = "Bundle-RequiredExecutionEnvironment";
+ String BUNDLE_SYMBOLICNAME = "Bundle-SymbolicName";
+ String BUNDLE_UPDATELOCATION = "Bundle-UpdateLocation";
+ String BUNDLE_VENDOR = "Bundle-Vendor";
+ String BUNDLE_VERSION = "Bundle-Version";
+ String DYNAMICIMPORT_PACKAGE = "DynamicImport-Package";
+ String EXPORT_PACKAGE = "Export-Package";
+ String EXPORT_SERVICE = "Export-Service";
+ String FRAGMENT_HOST = "Fragment-Host";
+ String IMPORT_PACKAGE = "Import-Package";
+ String IMPORT_SERVICE = "Import-Service";
+ String PROVIDE_CAPABILITY = "Provide-Capability";
+ String REQUIRE_BUNDLE = "Require-Bundle";
+ String REQUIRE_CAPABILITY = "Require-Capability";
+ String SERVICE_COMPONENT = "Service-Component";
+
+ String PRIVATE_PACKAGE = "Private-Package";
+ String IGNORE_PACKAGE = "Ignore-Package";
+ String INCLUDE_RESOURCE = "Include-Resource";
+ String CONDITIONAL_PACKAGE = "Conditional-Package";
+ String BND_LASTMODIFIED = "Bnd-LastModified";
+ String CREATED_BY = "Created-By";
+ String TOOL = "Tool";
+ String TESTCASES = "Test-Cases";
+ String SIGNATURE_TEST = "-signaturetest";
+
+ String headers[] = {
+ BUNDLE_ACTIVATOR, BUNDLE_CONTACTADDRESS, BUNDLE_COPYRIGHT, BUNDLE_DESCRIPTION, BUNDLE_DOCURL,
+ BUNDLE_LOCALIZATION, BUNDLE_NATIVECODE, BUNDLE_VENDOR, BUNDLE_VERSION, BUNDLE_LICENSE, BUNDLE_CLASSPATH,
+ SERVICE_COMPONENT, EXPORT_PACKAGE, IMPORT_PACKAGE, BUNDLE_LOCALIZATION, BUNDLE_MANIFESTVERSION,
+ BUNDLE_NAME, BUNDLE_NATIVECODE, BUNDLE_REQUIREDEXECUTIONENVIRONMENT, BUNDLE_SYMBOLICNAME, BUNDLE_VERSION,
+ FRAGMENT_HOST, PRIVATE_PACKAGE, IGNORE_PACKAGE, INCLUDE_RESOURCE, REQUIRE_BUNDLE, IMPORT_SERVICE,
+ EXPORT_SERVICE, CONDITIONAL_PACKAGE, BND_LASTMODIFIED, TESTCASES, SIGNATURE_TEST, REQUIRE_CAPABILITY,
+ PROVIDE_CAPABILITY
+ };
+
+ String BUILDPATH = "-buildpath";
+ String BUILDPACKAGES = "-buildpackages";
+ String BUMPPOLICY = "-bumppolicy";
+ String CONDUIT = "-conduit";
+ String COMPILER_SOURCE = "-source";
+ String COMPILER_TARGET = "-target";
+ String DEPENDSON = "-dependson";
+ String DEPLOY = "-deploy";
+ String DEPLOYREPO = "-deployrepo";
+ String DIGESTS = "-digests";
+ String DSANNOTATIONS = "-dsannotations";
+ String DONOTCOPY = "-donotcopy";
+ String DEBUG = "-debug";
+ String EXPORT_CONTENTS = "-exportcontents";
+ String FAIL_OK = "-failok";
+ String INCLUDE = "-include";
+ String INCLUDERESOURCE = "-includeresource";
+ String MAKE = "-make";
+ String METATYPE = "-metatype";
+ String MANIFEST = "-manifest";
+ String SAVEMANIFEST = "-savemanifest";
+ String NAMESECTION = "-namesection";
+ String NODEFAULTVERSION = "-nodefaultversion";
+ String NOEXTRAHEADERS = "-noextraheaders";
+ String NOMANIFEST = "-nomanifest";
+ String NOUSES = "-nouses";
@Deprecated
- String NOPE = "-nope";
- String NOBUNDLES = "-nobundles";
- String PEDANTIC = "-pedantic";
- String PLUGIN = "-plugin";
- String PLUGINPATH = "-pluginpath";
- String POM = "-pom";
- String RELEASEREPO = "-releaserepo";
- String REMOVEHEADERS = "-removeheaders";
- String RESOURCEONLY = "-resourceonly";
- String SOURCES = "-sources";
- String SOURCEPATH = "-sourcepath";
- String SUB = "-sub";
- String RUNPROPERTIES = "-runproperties";
- String RUNSYSTEMPACKAGES = "-runsystempackages";
- String RUNBUNDLES = "-runbundles";
- String RUNPATH = "-runpath";
- String RUNSTORAGE = "-runstorage";
- String RUNBUILDS = "-runbuilds";
- String RUNPATH_MAIN_DIRECTIVE = "main:";
- String RUNPATH_LAUNCHER_DIRECTIVE = "launcher:";
- String RUNVM = "-runvm";
- String RUNTRACE = "-runtrace";
- String RUNFRAMEWORK = "-runframework";
- String RUNTIMEOUT = "-runtimeout";
- String SNAPSHOT = "-snapshot";
- String RUNFRAMEWORK_SERVICES = "services";
- String RUNFRAMEWORK_NONE = "none";
- String REPORTNEWER = "-reportnewer";
- String SIGN = "-sign";
- String TESTPACKAGES = "-testpackages";
- String TESTREPORT = "-testreport";
- String TESTPATH = "-testpath";
- String TESTCONTINUOUS = "-testcontinuous";
- String UNDERTEST = "-undertest";
- String VERBOSE = "-verbose";
+ String NOPE = "-nope";
+ String NOBUNDLES = "-nobundles";
+ String PEDANTIC = "-pedantic";
+ String PLUGIN = "-plugin";
+ String PLUGINPATH = "-pluginpath";
+ String POM = "-pom";
+ String RELEASEREPO = "-releaserepo";
+ String REMOVEHEADERS = "-removeheaders";
+ String RESOURCEONLY = "-resourceonly";
+ String SOURCES = "-sources";
+ String SOURCEPATH = "-sourcepath";
+ String SUB = "-sub";
+ String RUNPROPERTIES = "-runproperties";
+ String RUNSYSTEMPACKAGES = "-runsystempackages";
+ String RUNBUNDLES = "-runbundles";
+ String RUNPATH = "-runpath";
+ String RUNSTORAGE = "-runstorage";
+ String RUNBUILDS = "-runbuilds";
+ String RUNPATH_MAIN_DIRECTIVE = "main:";
+ String RUNPATH_LAUNCHER_DIRECTIVE = "launcher:";
+ String RUNVM = "-runvm";
+ String RUNTRACE = "-runtrace";
+ String RUNFRAMEWORK = "-runframework";
+ String RUNTIMEOUT = "-runtimeout";
+ String SNAPSHOT = "-snapshot";
+ String RUNFRAMEWORK_SERVICES = "services";
+ String RUNFRAMEWORK_NONE = "none";
+ String REPORTNEWER = "-reportnewer";
+ String SIGN = "-sign";
+ String TESTPACKAGES = "-testpackages";
+ String TESTREPORT = "-testreport";
+ String TESTPATH = "-testpath";
+ String TESTCONTINUOUS = "-testcontinuous";
+ String UNDERTEST = "-undertest";
+ String VERBOSE = "-verbose";
@Deprecated
- String VERSIONPOLICY_IMPL = "-versionpolicy-impl";
+ String VERSIONPOLICY_IMPL = "-versionpolicy-impl";
@Deprecated
- String VERSIONPOLICY_USES = "-versionpolicy-uses";
- String PROVIDER_POLICY = "-provider-policy";
- String CONSUMER_POLICY = "-consumer-policy";
+ String VERSIONPOLICY_USES = "-versionpolicy-uses";
+ String PROVIDER_POLICY = "-provider-policy";
+ String CONSUMER_POLICY = "-consumer-policy";
@Deprecated
- String VERSIONPOLICY = "-versionpolicy";
- String WAB = "-wab";
- String WABLIB = "-wablib";
- String REQUIRE_BND = "-require-bnd";
+ String VERSIONPOLICY = "-versionpolicy";
+ String WAB = "-wab";
+ String WABLIB = "-wablib";
+ String REQUIRE_BND = "-require-bnd";
// Deprecated
- String CLASSPATH = "-classpath";
- String OUTPUT = "-output";
+ String CLASSPATH = "-classpath";
+ String OUTPUT = "-output";
- String options[] = {BUILDPATH,
- BUMPPOLICY, CONDUIT, CLASSPATH, CONSUMER_POLICY, DEPENDSON, DONOTCOPY, EXPORT_CONTENTS,
- FAIL_OK, INCLUDE, INCLUDERESOURCE, MAKE, MANIFEST, NOEXTRAHEADERS, NOUSES, NOBUNDLES,
- PEDANTIC, PLUGIN, POM, PROVIDER_POLICY, REMOVEHEADERS, RESOURCEONLY, SOURCES,
- SOURCEPATH, SOURCES, SOURCEPATH, SUB, RUNBUNDLES, RUNPATH, RUNSYSTEMPACKAGES,
- RUNPROPERTIES, REPORTNEWER, UNDERTEST, TESTPATH, TESTPACKAGES, TESTREPORT, VERBOSE,
- NOMANIFEST, DEPLOYREPO, RELEASEREPO, SAVEMANIFEST, RUNVM, WAB, WABLIB, RUNFRAMEWORK,
- RUNTRACE, TESTCONTINUOUS, SNAPSHOT, NAMESECTION, DIGESTS, DSANNOTATIONS };
+ String options[] = {
+ BUILDPATH, BUMPPOLICY, CONDUIT, CLASSPATH, CONSUMER_POLICY, DEPENDSON, DONOTCOPY, EXPORT_CONTENTS, FAIL_OK,
+ INCLUDE, INCLUDERESOURCE, MAKE, MANIFEST, NOEXTRAHEADERS, NOUSES, NOBUNDLES, PEDANTIC, PLUGIN, POM,
+ PROVIDER_POLICY, REMOVEHEADERS, RESOURCEONLY, SOURCES, SOURCEPATH, SOURCES, SOURCEPATH, SUB, RUNBUNDLES,
+ RUNPATH, RUNSYSTEMPACKAGES, RUNPROPERTIES, REPORTNEWER, UNDERTEST, TESTPATH, TESTPACKAGES, TESTREPORT,
+ VERBOSE, NOMANIFEST, DEPLOYREPO, RELEASEREPO, SAVEMANIFEST, RUNVM, WAB, WABLIB, RUNFRAMEWORK, RUNTRACE,
+ TESTCONTINUOUS, SNAPSHOT, NAMESECTION, DIGESTS, DSANNOTATIONS
+ };
// Ignore bundle specific headers. These bundles do not make
// a lot of sense to inherit
- String[] BUNDLE_SPECIFIC_HEADERS = new String[] {
- INCLUDE_RESOURCE, BUNDLE_ACTIVATOR, BUNDLE_CLASSPATH, BUNDLE_NAME, BUNDLE_NATIVECODE,
- BUNDLE_SYMBOLICNAME, IMPORT_PACKAGE, EXPORT_PACKAGE, DYNAMICIMPORT_PACKAGE,
- FRAGMENT_HOST, REQUIRE_BUNDLE, PRIVATE_PACKAGE, EXPORT_CONTENTS, TESTCASES, NOMANIFEST,
- SIGNATURE_TEST, WAB, WABLIB, REQUIRE_CAPABILITY, PROVIDE_CAPABILITY, DSANNOTATIONS, SERVICE_COMPONENT };
-
- char DUPLICATE_MARKER = '~';
- String SPECIFICATION_VERSION = "specification-version";
- String SPLIT_PACKAGE_DIRECTIVE = "-split-package:";
- String IMPORT_DIRECTIVE = "-import:";
- String NO_IMPORT_DIRECTIVE = "-noimport:";
- String REMOVE_ATTRIBUTE_DIRECTIVE = "-remove-attribute:";
- String LIB_DIRECTIVE = "lib:";
- String NOANNOTATIONS = "-noannotations";
- String COMMAND_DIRECTIVE = "command:";
- String USES_DIRECTIVE = "uses:";
- String MANDATORY_DIRECTIVE = "mandatory:";
- String INCLUDE_DIRECTIVE = "include:";
- String PROVIDE_DIRECTIVE = "provide:";
- String EXCLUDE_DIRECTIVE = "exclude:";
- String PRESENCE_DIRECTIVE = "presence:";
- String PRIVATE_DIRECTIVE = "private:";
- String SINGLETON_DIRECTIVE = "singleton:";
- String EXTENSION_DIRECTIVE = "extension:";
- String VISIBILITY_DIRECTIVE = "visibility:";
- String FRAGMENT_ATTACHMENT_DIRECTIVE = "fragment-attachment:";
- String RESOLUTION_DIRECTIVE = "resolution:";
- String PATH_DIRECTIVE = "path:";
- String SIZE_ATTRIBUTE = "size";
- String LINK_ATTRIBUTE = "link";
- String NAME_ATTRIBUTE = "name";
- String DESCRIPTION_ATTRIBUTE = "description";
- String OSNAME_ATTRIBUTE = "osname";
- String OSVERSION_ATTRIBUTE = "osversion";
- String PROCESSOR_ATTRIBUTE = "processor";
- String LANGUAGE_ATTRIBUTE = "language";
- String SELECTION_FILTER_ATTRIBUTE = "selection-filter";
- String BLUEPRINT_WAIT_FOR_DEPENDENCIES_ATTRIBUTE = "blueprint.wait-for-dependencies";
- String BLUEPRINT_TIMEOUT_ATTRIBUTE = "blueprint.timeout";
- String VERSION_ATTRIBUTE = "version";
- String BUNDLE_SYMBOLIC_NAME_ATTRIBUTE = "bundle-symbolic-name";
- String BUNDLE_VERSION_ATTRIBUTE = "bundle-version";
- String FROM_DIRECTIVE = "from:";
-
- String KEYSTORE_LOCATION_DIRECTIVE = "keystore:";
- String KEYSTORE_PROVIDER_DIRECTIVE = "provider:";
- String KEYSTORE_PASSWORD_DIRECTIVE = "password:";
- String SIGN_PASSWORD_DIRECTIVE = "sign-password:";
-
- String NONE = "none";
-
- String directives[] = {
- SPLIT_PACKAGE_DIRECTIVE, NO_IMPORT_DIRECTIVE, IMPORT_DIRECTIVE, RESOLUTION_DIRECTIVE,
- INCLUDE_DIRECTIVE, USES_DIRECTIVE, EXCLUDE_DIRECTIVE, KEYSTORE_LOCATION_DIRECTIVE,
- KEYSTORE_PROVIDER_DIRECTIVE, KEYSTORE_PASSWORD_DIRECTIVE, SIGN_PASSWORD_DIRECTIVE,
- COMMAND_DIRECTIVE, NOANNOTATIONS, LIB_DIRECTIVE, RUNPATH_LAUNCHER_DIRECTIVE,
- FROM_DIRECTIVE, PRIVATE_DIRECTIVE
-
- // TODO
- };
-
- String USES_USES = "<<USES>>";
- String CURRENT_USES = "@uses";
- String IMPORT_REFERENCE = "reference";
- String IMPORT_PRIVATE = "private";
- String[] importDirectives = {
- IMPORT_REFERENCE, IMPORT_PRIVATE };
-
- static final Pattern VALID_PROPERTY_TYPES = Pattern
- .compile("(String|Long|Double|Float|Integer|Byte|Character|Boolean|Short)");
-
- String DEFAULT_BND_EXTENSION = ".bnd";
- String DEFAULT_JAR_EXTENSION = ".jar";
- String DEFAULT_BAR_EXTENSION = ".bar";
- String DEFAULT_BNDRUN_EXTENSION = ".bndrun";
- String[] METAPACKAGES = {"META-INF",
- "OSGI-INF", "OSGI-OPT" };
-
- String CURRENT_VERSION = "@";
- String CURRENT_PACKAGE = "@package";
-
- String BUILDFILES = "buildfiles";
-
- String EMPTY_HEADER = "<<EMPTY>>";
-
- String EMBEDDED_REPO = "/embedded-repo.jar";
- String LAUNCHER_PLUGIN = "Launcher-Plugin";
- String TESTER_PLUGIN = "Tester-Plugin";
-
- String DEFAULT_LAUNCHER_BSN = "biz.aQute.launcher";
- String DEFAULT_TESTER_BSN = "biz.aQute.junit";
-
- String DEFAULT_DO_NOT_COPY = "CVS|\\.svn|\\.git|\\.DS_Store";
-
- Charset DEFAULT_CHARSET = Charset
- .forName("UTF8");
- String VERSION_FILTER = "version";
- String PROVIDER_TYPE_DIRECTIVE = "x-provider-type:";
+ String[] BUNDLE_SPECIFIC_HEADERS = new String[] {
+ INCLUDE_RESOURCE, BUNDLE_ACTIVATOR, BUNDLE_CLASSPATH, BUNDLE_NAME, BUNDLE_NATIVECODE, BUNDLE_SYMBOLICNAME,
+ IMPORT_PACKAGE, EXPORT_PACKAGE, DYNAMICIMPORT_PACKAGE, FRAGMENT_HOST, REQUIRE_BUNDLE, PRIVATE_PACKAGE,
+ EXPORT_CONTENTS, TESTCASES, NOMANIFEST, SIGNATURE_TEST, WAB, WABLIB, REQUIRE_CAPABILITY,
+ PROVIDE_CAPABILITY, DSANNOTATIONS, SERVICE_COMPONENT
+ };
+
+ char DUPLICATE_MARKER = '~';
+ String SPECIFICATION_VERSION = "specification-version";
+ String SPLIT_PACKAGE_DIRECTIVE = "-split-package:";
+ String IMPORT_DIRECTIVE = "-import:";
+ String NO_IMPORT_DIRECTIVE = "-noimport:";
+ String REMOVE_ATTRIBUTE_DIRECTIVE = "-remove-attribute:";
+ String LIB_DIRECTIVE = "lib:";
+ String NOANNOTATIONS = "-noannotations";
+ String COMMAND_DIRECTIVE = "command:";
+ String USES_DIRECTIVE = "uses:";
+ String MANDATORY_DIRECTIVE = "mandatory:";
+ String INCLUDE_DIRECTIVE = "include:";
+ String PROVIDE_DIRECTIVE = "provide:";
+ String EXCLUDE_DIRECTIVE = "exclude:";
+ String PRESENCE_DIRECTIVE = "presence:";
+ String PRIVATE_DIRECTIVE = "private:";
+ String SINGLETON_DIRECTIVE = "singleton:";
+ String EXTENSION_DIRECTIVE = "extension:";
+ String VISIBILITY_DIRECTIVE = "visibility:";
+ String FRAGMENT_ATTACHMENT_DIRECTIVE = "fragment-attachment:";
+ String RESOLUTION_DIRECTIVE = "resolution:";
+ String PATH_DIRECTIVE = "path:";
+ String SIZE_ATTRIBUTE = "size";
+ String LINK_ATTRIBUTE = "link";
+ String NAME_ATTRIBUTE = "name";
+ String DESCRIPTION_ATTRIBUTE = "description";
+ String OSNAME_ATTRIBUTE = "osname";
+ String OSVERSION_ATTRIBUTE = "osversion";
+ String PROCESSOR_ATTRIBUTE = "processor";
+ String LANGUAGE_ATTRIBUTE = "language";
+ String SELECTION_FILTER_ATTRIBUTE = "selection-filter";
+ String BLUEPRINT_WAIT_FOR_DEPENDENCIES_ATTRIBUTE = "blueprint.wait-for-dependencies";
+ String BLUEPRINT_TIMEOUT_ATTRIBUTE = "blueprint.timeout";
+ String VERSION_ATTRIBUTE = "version";
+ String BUNDLE_SYMBOLIC_NAME_ATTRIBUTE = "bundle-symbolic-name";
+ String BUNDLE_VERSION_ATTRIBUTE = "bundle-version";
+ String FROM_DIRECTIVE = "from:";
+
+ String KEYSTORE_LOCATION_DIRECTIVE = "keystore:";
+ String KEYSTORE_PROVIDER_DIRECTIVE = "provider:";
+ String KEYSTORE_PASSWORD_DIRECTIVE = "password:";
+ String SIGN_PASSWORD_DIRECTIVE = "sign-password:";
+
+ String NONE = "none";
+
+ String directives[] = {
+ SPLIT_PACKAGE_DIRECTIVE, NO_IMPORT_DIRECTIVE, IMPORT_DIRECTIVE, RESOLUTION_DIRECTIVE, INCLUDE_DIRECTIVE,
+ USES_DIRECTIVE, EXCLUDE_DIRECTIVE, KEYSTORE_LOCATION_DIRECTIVE, KEYSTORE_PROVIDER_DIRECTIVE,
+ KEYSTORE_PASSWORD_DIRECTIVE, SIGN_PASSWORD_DIRECTIVE, COMMAND_DIRECTIVE, NOANNOTATIONS, LIB_DIRECTIVE,
+ RUNPATH_LAUNCHER_DIRECTIVE, FROM_DIRECTIVE, PRIVATE_DIRECTIVE
+
+ // TODO
+ };
+
+ String USES_USES = "<<USES>>";
+ String CURRENT_USES = "@uses";
+ String IMPORT_REFERENCE = "reference";
+ String IMPORT_PRIVATE = "private";
+ String[] importDirectives = {
+ IMPORT_REFERENCE, IMPORT_PRIVATE
+ };
+
+ static final Pattern VALID_PROPERTY_TYPES = Pattern
+ .compile("(String|Long|Double|Float|Integer|Byte|Character|Boolean|Short)");
+
+ String DEFAULT_BND_EXTENSION = ".bnd";
+ String DEFAULT_JAR_EXTENSION = ".jar";
+ String DEFAULT_BAR_EXTENSION = ".bar";
+ String DEFAULT_BNDRUN_EXTENSION = ".bndrun";
+ String[] METAPACKAGES = {
+ "META-INF", "OSGI-INF", "OSGI-OPT"
+ };
+
+ String CURRENT_VERSION = "@";
+ String CURRENT_PACKAGE = "@package";
+
+ String BUILDFILES = "buildfiles";
+
+ String EMPTY_HEADER = "<<EMPTY>>";
+
+ String EMBEDDED_REPO = "/embedded-repo.jar";
+ String LAUNCHER_PLUGIN = "Launcher-Plugin";
+ String TESTER_PLUGIN = "Tester-Plugin";
+
+ String DEFAULT_LAUNCHER_BSN = "biz.aQute.launcher";
+ String DEFAULT_TESTER_BSN = "biz.aQute.junit";
+
+ String DEFAULT_DO_NOT_COPY = "CVS|\\.svn|\\.git|\\.DS_Store";
+
+ Charset DEFAULT_CHARSET = Charset.forName("UTF8");
+ String VERSION_FILTER = "version";
+ String PROVIDER_TYPE_DIRECTIVE = "x-provider-type:";
/**
* Component constants
*/
- public final static String NAMESPACE_STEM = "http://www.osgi.org/xmlns/scr";
- public final static String JIDENTIFIER = "<<identifier>>";
- public final static String COMPONENT_NAME = "name:";
- public final static String COMPONENT_FACTORY = "factory:";
- public final static String COMPONENT_SERVICEFACTORY = "servicefactory:";
- public final static String COMPONENT_IMMEDIATE = "immediate:";
- public final static String COMPONENT_ENABLED = "enabled:";
- public final static String COMPONENT_DYNAMIC = "dynamic:";
- public final static String COMPONENT_MULTIPLE = "multiple:";
- public final static String COMPONENT_PROVIDE = "provide:";
- public final static String COMPONENT_OPTIONAL = "optional:";
- public final static String COMPONENT_PROPERTIES = "properties:";
- public final static String COMPONENT_IMPLEMENTATION = "implementation:";
- public final static String COMPONENT_DESIGNATE = "designate:";
- public final static String COMPONENT_DESIGNATEFACTORY = "designateFactory:";
- public final static String COMPONENT_DESCRIPTORS = ".descriptors:";
+ public final static String NAMESPACE_STEM = "http://www.osgi.org/xmlns/scr";
+ public final static String JIDENTIFIER = "<<identifier>>";
+ public final static String COMPONENT_NAME = "name:";
+ public final static String COMPONENT_FACTORY = "factory:";
+ public final static String COMPONENT_SERVICEFACTORY = "servicefactory:";
+ public final static String COMPONENT_IMMEDIATE = "immediate:";
+ public final static String COMPONENT_ENABLED = "enabled:";
+ public final static String COMPONENT_DYNAMIC = "dynamic:";
+ public final static String COMPONENT_MULTIPLE = "multiple:";
+ public final static String COMPONENT_PROVIDE = "provide:";
+ public final static String COMPONENT_OPTIONAL = "optional:";
+ public final static String COMPONENT_PROPERTIES = "properties:";
+ public final static String COMPONENT_IMPLEMENTATION = "implementation:";
+ public final static String COMPONENT_DESIGNATE = "designate:";
+ public final static String COMPONENT_DESIGNATEFACTORY = "designateFactory:";
+ public final static String COMPONENT_DESCRIPTORS = ".descriptors:";
// v1.1.0
- public final static String COMPONENT_VERSION = "version:";
- public final static String COMPONENT_CONFIGURATION_POLICY = "configuration-policy:";
- public final static String COMPONENT_MODIFIED = "modified:";
- public final static String COMPONENT_ACTIVATE = "activate:";
- public final static String COMPONENT_DEACTIVATE = "deactivate:";
-
- final static Map<String, String> EMPTY = Collections
- .emptyMap();
-
- public final static String[] componentDirectives = new String[] {
- COMPONENT_FACTORY, COMPONENT_IMMEDIATE, COMPONENT_ENABLED, COMPONENT_DYNAMIC,
- COMPONENT_MULTIPLE, COMPONENT_PROVIDE, COMPONENT_OPTIONAL, COMPONENT_PROPERTIES,
- COMPONENT_IMPLEMENTATION, COMPONENT_SERVICEFACTORY, COMPONENT_VERSION,
- COMPONENT_CONFIGURATION_POLICY, COMPONENT_MODIFIED, COMPONENT_ACTIVATE,
- COMPONENT_DEACTIVATE, COMPONENT_NAME, COMPONENT_DESCRIPTORS, COMPONENT_DESIGNATE,
- COMPONENT_DESIGNATEFACTORY };
-
- public final static Set<String> SET_COMPONENT_DIRECTIVES = new HashSet<String>(
- Arrays.asList(componentDirectives));
-
- public final static Set<String> SET_COMPONENT_DIRECTIVES_1_1 = //
- new HashSet<String>(
- Arrays.asList(
- COMPONENT_VERSION,
- COMPONENT_CONFIGURATION_POLICY,
- COMPONENT_MODIFIED,
- COMPONENT_ACTIVATE,
- COMPONENT_DEACTIVATE));
+ public final static String COMPONENT_VERSION = "version:";
+ public final static String COMPONENT_CONFIGURATION_POLICY = "configuration-policy:";
+ public final static String COMPONENT_MODIFIED = "modified:";
+ public final static String COMPONENT_ACTIVATE = "activate:";
+ public final static String COMPONENT_DEACTIVATE = "deactivate:";
+
+ final static Map<String,String> EMPTY = Collections.emptyMap();
+
+ public final static String[] componentDirectives = new String[] {
+ COMPONENT_FACTORY, COMPONENT_IMMEDIATE, COMPONENT_ENABLED, COMPONENT_DYNAMIC, COMPONENT_MULTIPLE,
+ COMPONENT_PROVIDE, COMPONENT_OPTIONAL, COMPONENT_PROPERTIES, COMPONENT_IMPLEMENTATION,
+ COMPONENT_SERVICEFACTORY, COMPONENT_VERSION, COMPONENT_CONFIGURATION_POLICY, COMPONENT_MODIFIED,
+ COMPONENT_ACTIVATE, COMPONENT_DEACTIVATE, COMPONENT_NAME, COMPONENT_DESCRIPTORS, COMPONENT_DESIGNATE,
+ COMPONENT_DESIGNATEFACTORY
+ };
+
+ public final static Set<String> SET_COMPONENT_DIRECTIVES = new HashSet<String>(
+ Arrays.asList(componentDirectives));
+
+ public final static Set<String> SET_COMPONENT_DIRECTIVES_1_1 = //
+ new HashSet<String>(Arrays.asList(
+ COMPONENT_VERSION,
+ COMPONENT_CONFIGURATION_POLICY,
+ COMPONENT_MODIFIED,
+ COMPONENT_ACTIVATE,
+ COMPONENT_DEACTIVATE));
}
Modified: felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Descriptors.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Descriptors.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Descriptors.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Descriptors.java Fri Jun 15 13:27:53 2012
@@ -5,30 +5,29 @@ import java.util.*;
import aQute.libg.generics.*;
public class Descriptors {
- Map<String, TypeRef> typeRefCache = Create.map();
- Map<String, Descriptor> descriptorCache = Create.map();
- Map<String, PackageRef> packageCache = Create.map();
+ Map<String,TypeRef> typeRefCache = Create.map();
+ Map<String,Descriptor> descriptorCache = Create.map();
+ Map<String,PackageRef> packageCache = Create.map();
// MUST BE BEFORE PRIMITIVES, THEY USE THE DEFAULT PACKAGE!!
- final static PackageRef DEFAULT_PACKAGE = new PackageRef();
+ final static PackageRef DEFAULT_PACKAGE = new PackageRef();
final static PackageRef PRIMITIVE_PACKAGE = new PackageRef();
-
- final static TypeRef VOID = new ConcreteRef("V", "void", PRIMITIVE_PACKAGE);
- final static TypeRef BOOLEAN = new ConcreteRef("Z", "boolean", PRIMITIVE_PACKAGE);
- final static TypeRef BYTE = new ConcreteRef("B", "byte", PRIMITIVE_PACKAGE);
- final static TypeRef CHAR = new ConcreteRef("C", "char", PRIMITIVE_PACKAGE);
- final static TypeRef SHORT = new ConcreteRef("S", "short", PRIMITIVE_PACKAGE);
- final static TypeRef INTEGER = new ConcreteRef("I", "int", PRIMITIVE_PACKAGE);
- final static TypeRef LONG = new ConcreteRef("J", "long", PRIMITIVE_PACKAGE);
- final static TypeRef DOUBLE = new ConcreteRef("D", "double", PRIMITIVE_PACKAGE);
- final static TypeRef FLOAT = new ConcreteRef("F", "float", PRIMITIVE_PACKAGE);
+ final static TypeRef VOID = new ConcreteRef("V", "void", PRIMITIVE_PACKAGE);
+ final static TypeRef BOOLEAN = new ConcreteRef("Z", "boolean", PRIMITIVE_PACKAGE);
+ final static TypeRef BYTE = new ConcreteRef("B", "byte", PRIMITIVE_PACKAGE);
+ final static TypeRef CHAR = new ConcreteRef("C", "char", PRIMITIVE_PACKAGE);
+ final static TypeRef SHORT = new ConcreteRef("S", "short", PRIMITIVE_PACKAGE);
+ final static TypeRef INTEGER = new ConcreteRef("I", "int", PRIMITIVE_PACKAGE);
+ final static TypeRef LONG = new ConcreteRef("J", "long", PRIMITIVE_PACKAGE);
+ final static TypeRef DOUBLE = new ConcreteRef("D", "double", PRIMITIVE_PACKAGE);
+ final static TypeRef FLOAT = new ConcreteRef("F", "float", PRIMITIVE_PACKAGE);
{
packageCache.put("", DEFAULT_PACKAGE);
}
- public interface TypeRef extends Comparable<TypeRef>{
+ public interface TypeRef extends Comparable<TypeRef> {
String getBinary();
String getFQN();
@@ -55,7 +54,7 @@ public class Descriptors {
}
- public static class PackageRef implements Comparable<PackageRef>{
+ public static class PackageRef implements Comparable<PackageRef> {
final String binaryName;
final String fqn;
final boolean java;
@@ -63,21 +62,23 @@ public class Descriptors {
private PackageRef(String binaryName) {
this.binaryName = fqnToBinary(binaryName);
this.fqn = binaryToFQN(binaryName);
- this.java = this.fqn.startsWith("java.") ; // && !this.fqn.equals("java.sql)"
-
+ this.java = this.fqn.startsWith("java."); // &&
+ // !this.fqn.equals("java.sql)"
+
// For some reason I excluded java.sql but the classloader will
// delegate anyway. So lost the understanding why I did it??
}
private PackageRef() {
this.binaryName = "";
- this.fqn=".";
+ this.fqn = ".";
this.java = false;
}
public PackageRef getDuplicate() {
- return new PackageRef(binaryName+Constants.DUPLICATE_MARKER);
+ return new PackageRef(binaryName + Constants.DUPLICATE_MARKER);
}
+
public String getFQN() {
return fqn;
}
@@ -97,7 +98,7 @@ public class Descriptors {
public String toString() {
return fqn;
}
-
+
boolean isDefaultPackage() {
return this.fqn.equals(".");
}
@@ -109,16 +110,16 @@ public class Descriptors {
public int compareTo(PackageRef other) {
return fqn.compareTo(other.fqn);
}
-
+
public boolean equals(Object o) {
assert o instanceof PackageRef;
return o == this;
}
-
+
public int hashCode() {
return super.hashCode();
}
-
+
/**
* Decide if the package is a metadata package.
*
@@ -128,7 +129,7 @@ public class Descriptors {
public boolean isMetaData() {
if (isDefaultPackage())
return true;
-
+
for (int i = 0; i < Constants.METAPACKAGES.length; i++) {
if (fqn.startsWith(Constants.METAPACKAGES[i]))
return true;
@@ -146,7 +147,7 @@ public class Descriptors {
final PackageRef packageRef;
ConcreteRef(PackageRef packageRef, String binaryName) {
- if ( packageRef.getFQN().length() < 2 )
+ if (packageRef.getFQN().length() < 2)
System.err.println("in default pack? " + binaryName);
this.binaryName = binaryName;
this.fqn = binaryToFQN(binaryName);
@@ -220,11 +221,11 @@ public class Descriptors {
}
public int compareTo(TypeRef other) {
- if ( this == other)
+ if (this == other)
return 0;
return fqn.compareTo(other.getFQN());
}
-
+
}
private static class ArrayRef implements TypeRef {
@@ -249,7 +250,7 @@ public class Descriptors {
public String getSourcePath() {
return component.getSourcePath();
}
-
+
public boolean isPrimitive() {
return false;
}
@@ -294,17 +295,17 @@ public class Descriptors {
}
public int compareTo(TypeRef other) {
- if ( this == other)
+ if (this == other)
return 0;
-
+
return getFQN().compareTo(other.getFQN());
}
}
- public TypeRef getTypeRef(String binaryClassName) {
+ public TypeRef getTypeRef(String binaryClassName) {
assert !binaryClassName.endsWith(".class");
-
+
TypeRef ref = typeRefCache.get(binaryClassName);
if (ref != null)
return ref;
@@ -315,34 +316,34 @@ public class Descriptors {
} else {
if (binaryClassName.length() >= 1) {
switch (binaryClassName.charAt(0)) {
- case 'V':
- return VOID;
- case 'B':
- return BYTE;
- case 'C':
- return CHAR;
- case 'I':
- return INTEGER;
- case 'S':
- return SHORT;
- case 'D':
- return DOUBLE;
- case 'F':
- return FLOAT;
- case 'J':
- return LONG;
- case 'Z':
- return BOOLEAN;
- case 'L':
- binaryClassName = binaryClassName.substring(1, binaryClassName.length() - 1);
- break;
+ case 'V' :
+ return VOID;
+ case 'B' :
+ return BYTE;
+ case 'C' :
+ return CHAR;
+ case 'I' :
+ return INTEGER;
+ case 'S' :
+ return SHORT;
+ case 'D' :
+ return DOUBLE;
+ case 'F' :
+ return FLOAT;
+ case 'J' :
+ return LONG;
+ case 'Z' :
+ return BOOLEAN;
+ case 'L' :
+ binaryClassName = binaryClassName.substring(1, binaryClassName.length() - 1);
+ break;
}
// falls trough for other 1 letter class names
}
ref = typeRefCache.get(binaryClassName);
- if ( ref != null)
+ if (ref != null)
return ref;
-
+
PackageRef pref;
int n = binaryClassName.lastIndexOf('/');
if (n < 0)
@@ -352,13 +353,13 @@ public class Descriptors {
ref = new ConcreteRef(pref, binaryClassName);
}
-
+
typeRefCache.put(binaryClassName, ref);
return ref;
}
public PackageRef getPackageRef(String binaryPackName) {
- if (binaryPackName.indexOf('.') >= 0 ) {
+ if (binaryPackName.indexOf('.') >= 0) {
binaryPackName = binaryPackName.replace('.', '/');
}
PackageRef ref = packageCache.get(binaryPackName);
@@ -411,28 +412,28 @@ public class Descriptors {
}
switch (c) {
- case 'L':
- while ((c = descriptor.charAt(index++)) != ';') {
- // TODO
- sb.append(c);
- }
- break;
+ case 'L' :
+ while ((c = descriptor.charAt(index++)) != ';') {
+ // TODO
+ sb.append(c);
+ }
+ break;
- case 'V':
- case 'B':
- case 'C':
- case 'I':
- case 'S':
- case 'D':
- case 'F':
- case 'J':
- case 'Z':
- sb.append(c);
- break;
+ case 'V' :
+ case 'B' :
+ case 'C' :
+ case 'I' :
+ case 'S' :
+ case 'D' :
+ case 'F' :
+ case 'J' :
+ case 'Z' :
+ sb.append(c);
+ break;
- default:
- throw new IllegalArgumentException("Invalid type in descriptor: " + c + " from "
- + descriptor + "[" + index + "]");
+ default :
+ throw new IllegalArgumentException("Invalid type in descriptor: " + c + " from " + descriptor + "["
+ + index + "]");
}
types.add(getTypeRef(sb.toString()));
return index;
@@ -450,13 +451,11 @@ public class Descriptors {
if (other == null || other.getClass() != getClass())
return false;
- return Arrays.equals(prototype, ((Descriptor) other).prototype)
- && type == ((Descriptor) other).type;
+ return Arrays.equals(prototype, ((Descriptor) other).prototype) && type == ((Descriptor) other).type;
}
public int hashCode() {
- return prototype == null ? type.hashCode() : type.hashCode()
- ^ Arrays.hashCode(prototype);
+ return prototype == null ? type.hashCode() : type.hashCode() ^ Arrays.hashCode(prototype);
}
public String toString() {
@@ -470,7 +469,7 @@ public class Descriptors {
public static String getShortName(String fqn) {
assert fqn.indexOf('/') < 0;
-
+
int n = fqn.lastIndexOf('.');
if (n >= 0) {
return fqn.substring(n + 1);
@@ -480,10 +479,10 @@ public class Descriptors {
public static String binaryToFQN(String binary) {
StringBuilder sb = new StringBuilder();
- for ( int i=0, l=binary.length(); i<l; i++) {
+ for (int i = 0, l = binary.length(); i < l; i++) {
char c = binary.charAt(i);
-
- if ( c == '/')
+
+ if (c == '/')
sb.append('.');
else
sb.append(c);
@@ -514,35 +513,35 @@ public class Descriptors {
}
public TypeRef getTypeRefFromFQN(String fqn) {
- if ( fqn.equals("boolean"))
+ if (fqn.equals("boolean"))
return BOOLEAN;
-
- if ( fqn.equals("byte"))
+
+ if (fqn.equals("byte"))
return BOOLEAN;
-
- if ( fqn.equals("char"))
+
+ if (fqn.equals("char"))
return CHAR;
-
- if ( fqn.equals("short"))
+
+ if (fqn.equals("short"))
return SHORT;
-
- if ( fqn.equals("int"))
+
+ if (fqn.equals("int"))
return INTEGER;
-
- if ( fqn.equals("long"))
+
+ if (fqn.equals("long"))
return LONG;
-
- if ( fqn.equals("float"))
+
+ if (fqn.equals("float"))
return FLOAT;
-
- if ( fqn.equals("double"))
+
+ if (fqn.equals("double"))
return DOUBLE;
-
+
return getTypeRef(fqnToBinary(fqn));
}
public TypeRef getTypeRefFromPath(String path) {
assert path.endsWith(".class");
- return getTypeRef(path.substring(0,path.length()-6));
+ return getTypeRef(path.substring(0, path.length() - 6));
}
}
Modified: felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Domain.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Domain.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Domain.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Domain.java Fri Jun 15 13:27:53 2012
@@ -13,7 +13,6 @@ import aQute.libg.version.*;
* This class abstracts domains that have properties holding OSGi meta data. It
* provides access to the keys, the set method and the get method. It then
* provides convenient methods to access these properties via semantic methods.
- *
*/
public abstract class Domain implements Iterable<String> {
@@ -38,15 +37,18 @@ public abstract class Domain implements
public static Domain domain(final Attributes attrs) {
return new Domain() {
- @Override public String get(String key) {
+ @Override
+ public String get(String key) {
return attrs.getValue(key);
}
- @Override public void set(String key, String value) {
+ @Override
+ public void set(String key, String value) {
attrs.putValue(key, value);
}
- @Override public Iterator<String> iterator() {
+ @Override
+ public Iterator<String> iterator() {
final Iterator<Object> it = attrs.keySet().iterator();
return new Iterator<String>() {
@@ -70,19 +72,23 @@ public abstract class Domain implements
public static Domain domain(final Processor processor) {
return new Domain() {
- @Override public String get(String key) {
+ @Override
+ public String get(String key) {
return processor.getProperty(key);
}
- @Override public String get(String key, String deflt) {
+ @Override
+ public String get(String key, String deflt) {
return processor.getProperty(key, deflt);
}
- @Override public void set(String key, String value) {
+ @Override
+ public void set(String key, String value) {
processor.setProperty(key, value);
}
- @Override public Iterator<String> iterator() {
+ @Override
+ public Iterator<String> iterator() {
final Iterator<String> it = processor.getPropertyKeys(true).iterator();
return new Iterator<String>() {
@@ -104,18 +110,21 @@ public abstract class Domain implements
};
}
- public static Domain domain(final Map<String, String> map) {
+ public static Domain domain(final Map<String,String> map) {
return new Domain() {
- @Override public String get(String key) {
+ @Override
+ public String get(String key) {
return map.get(key);
}
- @Override public void set(String key, String value) {
+ @Override
+ public void set(String key, String value) {
map.put(key, value);
}
- @Override public Iterator<String> iterator() {
+ @Override
+ public Iterator<String> iterator() {
return map.keySet().iterator();
}
};
@@ -155,7 +164,7 @@ public abstract class Domain implements
public Parameters getIncludeResource() {
Parameters ic = getParameters(INCLUDE_RESOURCE);
- ic.putAll( getParameters(INCLUDERESOURCE));
+ ic.putAll(getParameters(INCLUDERESOURCE));
return ic;
}
@@ -232,24 +241,24 @@ public abstract class Domain implements
public void setBundleSymbolicName(String s) {
set(BUNDLE_SYMBOLICNAME, s);
}
-
+
public String getBundleVersion() {
return get(BUNDLE_VERSION);
}
public void setBundleVersion(String version) {
Version v = new Version(version);
- set(BUNDLE_VERSION,v.toString());
+ set(BUNDLE_VERSION, v.toString());
}
public void setBundleVersion(Version version) {
- set(BUNDLE_VERSION,version.toString());
+ set(BUNDLE_VERSION, version.toString());
}
public void setFailOk(boolean b) {
- set(FAIL_OK, b+"");
+ set(FAIL_OK, b + "");
}
-
+
public boolean isFailOk() {
return Processor.isTrue(get(FAIL_OK));
}
Modified: felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/EmbeddedResource.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/EmbeddedResource.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/EmbeddedResource.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/EmbeddedResource.java Fri Jun 15 13:27:53 2012
@@ -75,7 +75,8 @@ public class EmbeddedResource implements
InputStream in = resource.openInputStream();
try {
build(sub, in, resource.lastModified());
- } catch( Exception e ) {
+ }
+ catch (Exception e) {
e.printStackTrace();
}
finally {
Modified: felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/FileResource.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/FileResource.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/FileResource.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/FileResource.java Fri Jun 15 13:27:53 2012
@@ -6,7 +6,7 @@ import java.util.regex.*;
public class FileResource implements Resource {
File file;
String extra;
-
+
public FileResource(File file) {
this.file = file;
}
@@ -16,11 +16,7 @@ public class FileResource implements Res
}
public static void build(Jar jar, File directory, Pattern doNotCopy) {
- traverse(
- jar,
- directory.getAbsolutePath().length(),
- directory,
- doNotCopy);
+ traverse(jar, directory.getAbsolutePath().length(), directory, doNotCopy);
}
public String toString() {
@@ -31,8 +27,7 @@ public class FileResource implements Res
copy(this, out);
}
- static synchronized void copy(Resource resource, OutputStream out)
- throws Exception {
+ static synchronized void copy(Resource resource, OutputStream out) throws Exception {
InputStream in = resource.openInputStream();
try {
byte buffer[] = new byte[20000];
@@ -47,19 +42,17 @@ public class FileResource implements Res
}
}
- static void traverse(Jar jar, int rootlength, File directory,
- Pattern doNotCopy) {
+ static void traverse(Jar jar, int rootlength, File directory, Pattern doNotCopy) {
if (doNotCopy != null && doNotCopy.matcher(directory.getName()).matches())
return;
jar.updateModified(directory.lastModified(), "Dir change");
-
+
File files[] = directory.listFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory())
traverse(jar, rootlength, files[i], doNotCopy);
else {
- String path = files[i].getAbsolutePath().substring(
- rootlength + 1);
+ String path = files[i].getAbsolutePath().substring(rootlength + 1);
if (File.separatorChar != '/')
path = path.replace(File.separatorChar, '/');
jar.putResource(path, new FileResource(files[i]), true);
@@ -78,8 +71,8 @@ public class FileResource implements Res
public void setExtra(String extra) {
this.extra = extra;
}
-
+
public long size() {
- return (int) file.length();
+ return (int) file.length();
}
}
Modified: felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Instruction.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Instruction.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Instruction.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Instruction.java Fri Jun 15 13:27:53 2012
@@ -60,8 +60,7 @@ public class Instruction {
if (s.startsWith("!")) {
negated = true;
s = s.substring(1);
- }
- else
+ } else
negated = false;
if (input.equals("*")) {
@@ -75,8 +74,7 @@ public class Instruction {
if (s.startsWith("=")) {
match = s.substring(1);
literal = true;
- }
- else {
+ } else {
boolean wildcards = false;
StringBuilder sb = new StringBuilder();
@@ -90,8 +88,7 @@ public class Instruction {
sb.append("(\\..*)?");
wildcards = true;
break loop;
- }
- else
+ } else
sb.append("\\.");
break;
@@ -119,8 +116,7 @@ public class Instruction {
if (!wildcards) {
literal = true;
match = s;
- }
- else {
+ } else {
literal = false;
match = sb.toString();
}
Modified: felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Instructions.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Instructions.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Instructions.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Instructions.java Fri Jun 15 13:27:53 2012
@@ -4,25 +4,24 @@ import java.util.*;
import aQute.libg.header.*;
-public class Instructions implements Map<Instruction, Attrs> {
- private LinkedHashMap<Instruction, Attrs> map;
- static Map<Instruction, Attrs> EMPTY = Collections.emptyMap();
+public class Instructions implements Map<Instruction,Attrs> {
+ private LinkedHashMap<Instruction,Attrs> map;
+ static Map<Instruction,Attrs> EMPTY = Collections.emptyMap();
public Instructions(Instructions other) {
if (other.map != null && !other.map.isEmpty()) {
- map = new LinkedHashMap<Instruction, Attrs>(other.map);
+ map = new LinkedHashMap<Instruction,Attrs>(other.map);
}
}
public Instructions(Collection<String> other) {
- if ( other != null)
- for ( String s : other ) {
- put( new Instruction(s), null);
+ if (other != null)
+ for (String s : other) {
+ put(new Instruction(s), null);
}
}
- public Instructions() {
- }
+ public Instructions() {}
public Instructions(Parameters contained) {
append(contained);
@@ -43,7 +42,8 @@ public class Instructions implements Map
return map.containsKey(name);
}
- @Deprecated public boolean containsKey(Object name) {
+ @Deprecated
+ public boolean containsKey(Object name) {
assert name instanceof Instruction;
if (map == null)
return false;
@@ -58,7 +58,8 @@ public class Instructions implements Map
return map.containsValue(value);
}
- @Deprecated public boolean containsValue(Object value) {
+ @Deprecated
+ public boolean containsValue(Object value) {
assert value instanceof Attrs;
if (map == null)
return false;
@@ -66,14 +67,15 @@ public class Instructions implements Map
return map.containsValue((Attrs) value);
}
- public Set<java.util.Map.Entry<Instruction, Attrs>> entrySet() {
+ public Set<java.util.Map.Entry<Instruction,Attrs>> entrySet() {
if (map == null)
return EMPTY.entrySet();
return map.entrySet();
}
- @Deprecated public Attrs get(Object key) {
+ @Deprecated
+ public Attrs get(Object key) {
assert key instanceof Instruction;
if (map == null)
return null;
@@ -101,21 +103,22 @@ public class Instructions implements Map
public Attrs put(Instruction key, Attrs value) {
if (map == null)
- map = new LinkedHashMap<Instruction, Attrs>();
+ map = new LinkedHashMap<Instruction,Attrs>();
return map.put(key, value);
}
- public void putAll(Map<? extends Instruction, ? extends Attrs> map) {
+ public void putAll(Map< ? extends Instruction, ? extends Attrs> map) {
if (this.map == null)
if (map.isEmpty())
return;
else
- this.map = new LinkedHashMap<Instruction, Attrs>();
+ this.map = new LinkedHashMap<Instruction,Attrs>();
this.map.putAll(map);
}
- @Deprecated public Attrs remove(Object var0) {
+ @Deprecated
+ public Attrs remove(Object var0) {
assert var0 instanceof Instruction;
if (map == null)
return null;
@@ -147,19 +150,20 @@ public class Instructions implements Map
}
public void append(Parameters other) {
- for (Map.Entry<String, Attrs> e : other.entrySet()) {
- put( new Instruction(e.getKey()), e.getValue());
+ for (Map.Entry<String,Attrs> e : other.entrySet()) {
+ put(new Instruction(e.getKey()), e.getValue());
}
}
+
public <T> Collection<T> select(Collection<T> set, boolean emptyIsAll) {
- return select(set,null, emptyIsAll);
+ return select(set, null, emptyIsAll);
}
-
+
public <T> Collection<T> select(Collection<T> set, Set<Instruction> unused, boolean emptyIsAll) {
List<T> input = new ArrayList<T>(set);
- if ( emptyIsAll && isEmpty())
+ if (emptyIsAll && isEmpty())
return input;
-
+
List<T> result = new ArrayList<T>();
for (Instruction instruction : keySet()) {
@@ -174,13 +178,12 @@ public class Instructions implements Map
used = true;
}
}
- if ( !used && unused != null)
+ if (!used && unused != null)
unused.add(instruction);
}
return result;
}
-
public <T> Collection<T> reject(Collection<T> set) {
List<T> input = new ArrayList<T>(set);
List<T> result = new ArrayList<T>();
@@ -195,22 +198,22 @@ public class Instructions implements Map
o.remove();
} else
result.add(oo);
-
+
}
}
return result;
}
public boolean matches(String value) {
- if ( size() == 0)
+ if (size() == 0)
return true;
-
- for ( Instruction i : keySet()) {
- if ( i.matches(value)) {
- if ( i.isNegated())
- return false; // we deny this one explicitly
+
+ for (Instruction i : keySet()) {
+ if (i.matches(value)) {
+ if (i.isNegated())
+ return false; // we deny this one explicitly
else
- return true; // we allow it explicitly
+ return true; // we allow it explicitly
}
}
return false;