Latest bnd code
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1350613 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/About.java b/bundleplugin/src/main/java/aQute/lib/osgi/About.java
index 7265212..0fdf402 100755
--- a/bundleplugin/src/main/java/aQute/lib/osgi/About.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/About.java
@@ -4,48 +4,36 @@
/**
* This package contains a number of classes that assists by analyzing JARs and
- * constructing bundles.
- *
- * The Analyzer class can be used to analyze an existing bundle and can create a
- * manifest specification from proposed (wildcard) Export-Package,
- * Bundle-Includes, and Import-Package headers.
- *
- * The Builder class can use the headers to construct a JAR from the classpath.
- *
- * The Verifier class can take an existing JAR and verify that all headers are
- * correctly set. It will verify the syntax of the headers, match it against the
- * proper contents, and verify imports and exports.
- *
- * A number of utility classes are available.
- *
- * Jar, provides an abstraction of a Jar file. It has constructors for creating
- * a Jar from a stream, a directory, or a jar file. A Jar, keeps a collection
- * Resource's. There are Resource implementations for File, from ZipFile, or
- * from a stream (which copies the data). The Jar tries to minimize the work
- * during build up so that it is cheap to use. The Resource's can be used to
- * iterate over the names and later read the resources when needed.
- *
+ * constructing bundles. The Analyzer class can be used to analyze an existing
+ * bundle and can create a manifest specification from proposed (wildcard)
+ * Export-Package, Bundle-Includes, and Import-Package headers. The Builder
+ * class can use the headers to construct a JAR from the classpath. The Verifier
+ * class can take an existing JAR and verify that all headers are correctly set.
+ * It will verify the syntax of the headers, match it against the proper
+ * contents, and verify imports and exports. A number of utility classes are
+ * available. Jar, provides an abstraction of a Jar file. It has constructors
+ * for creating a Jar from a stream, a directory, or a jar file. A Jar, keeps a
+ * collection Resource's. There are Resource implementations for File, from
+ * ZipFile, or from a stream (which copies the data). The Jar tries to minimize
+ * the work during build up so that it is cheap to use. The Resource's can be
+ * used to iterate over the names and later read the resources when needed.
* Clazz, provides a parser for the class files. This will be used to define the
- * imports and exports.
- *
- * Headers are translated to {@link Parameters} that contains all headers (the
- * order is maintained). The attribute of each header are maintained in an
- * {@link Attrs}. Each additional file in a header definition will have its own
- * entry (only native code does not work this way). The ':' of directives is
- * considered part of the name. This allows attributes and directives to be
- * maintained in the Attributes map.
- *
- * An important aspect of the specification is to allow the use of wildcards.
- * Wildcards select from a set and can decorate the entries with new attributes.
- * This functionality is implemented in Instructions.
- *
- * Much of the information calculated is in packages. A package is identified
- * by a PackageRef (and a type by a TypeRef). The namespace is maintained
- * by {@link Descriptors}, which here is owned by {@link Analyzer}. A special
- * class, {@link Packages} maintains the attributes that are found in the code.
+ * imports and exports. Headers are translated to {@link Parameters} that
+ * contains all headers (the order is maintained). The attribute of each header
+ * are maintained in an {@link Attrs}. Each additional file in a header
+ * definition will have its own entry (only native code does not work this way).
+ * The ':' of directives is considered part of the name. This allows attributes
+ * and directives to be maintained in the Attributes map. An important aspect of
+ * the specification is to allow the use of wildcards. Wildcards select from a
+ * set and can decorate the entries with new attributes. This functionality is
+ * implemented in Instructions. Much of the information calculated is in
+ * packages. A package is identified by a PackageRef (and a type by a TypeRef).
+ * The namespace is maintained by {@link Descriptors}, which here is owned by
+ * {@link Analyzer}. A special class, {@link Packages} maintains the attributes
+ * that are found in the code.
*
* @version $Revision$
*/
public class About {
-
+ // Empty
}
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/AbstractResource.java b/bundleplugin/src/main/java/aQute/lib/osgi/AbstractResource.java
index 4c52103..782e615 100644
--- a/bundleplugin/src/main/java/aQute/lib/osgi/AbstractResource.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/AbstractResource.java
@@ -3,52 +3,54 @@
import java.io.*;
public abstract class AbstractResource implements Resource {
- String extra;
- byte[] calculated;
- long lastModified;
+ String extra;
+ byte[] calculated;
+ long lastModified;
- protected AbstractResource(long modified) {
- lastModified = modified;
- }
+ protected AbstractResource(long modified) {
+ lastModified = modified;
+ }
- public String getExtra() {
- return extra;
- }
+ public String getExtra() {
+ return extra;
+ }
- public long lastModified() {
- return lastModified;
- }
+ public long lastModified() {
+ return lastModified;
+ }
- public InputStream openInputStream() throws IOException {
- return new ByteArrayInputStream(getLocalBytes());
- }
+ public InputStream openInputStream() throws IOException {
+ return new ByteArrayInputStream(getLocalBytes());
+ }
- private byte[] getLocalBytes() throws IOException {
- try {
- if (calculated != null)
- return calculated;
+ private byte[] getLocalBytes() throws IOException {
+ try {
+ if (calculated != null)
+ return calculated;
- return calculated = getBytes();
- } catch (IOException e) {
- throw e;
- } catch (Exception e) {
- IOException ee = new IOException("Opening resource");
- ee.initCause(e);
- throw ee;
- }
- }
+ return calculated = getBytes();
+ }
+ catch (IOException e) {
+ throw e;
+ }
+ catch (Exception e) {
+ IOException ee = new IOException("Opening resource");
+ ee.initCause(e);
+ throw ee;
+ }
+ }
- public void setExtra(String extra) {
- this.extra = extra;
- }
+ public void setExtra(String extra) {
+ this.extra = extra;
+ }
- public void write(OutputStream out) throws IOException {
- out.write(getLocalBytes());
- }
+ public void write(OutputStream out) throws IOException {
+ out.write(getLocalBytes());
+ }
- abstract protected byte[] getBytes() throws Exception;
-
- public long size() throws IOException {
- return getLocalBytes().length;
- }
+ abstract protected byte[] getBytes() throws Exception;
+
+ public long size() throws IOException {
+ return getLocalBytes().length;
+ }
}
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/Analyzer.java b/bundleplugin/src/main/java/aQute/lib/osgi/Analyzer.java
index 8be2edb..8af9bc7 100755
--- a/bundleplugin/src/main/java/aQute/lib/osgi/Analyzer.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/Analyzer.java
@@ -42,6 +42,7 @@
import aQute.libg.cryptography.*;
import aQute.libg.generics.*;
import aQute.libg.header.*;
+import aQute.libg.reporter.*;
import aQute.libg.version.Version;
public class Analyzer extends Processor {
@@ -57,30 +58,31 @@
private TypeRef activator;
// Global parameters
- private final MultiMap<PackageRef, PackageRef> uses = new MultiMap<PackageRef, PackageRef>(
- PackageRef.class,
- PackageRef.class,
+ private final MultiMap<PackageRef,PackageRef> uses = new MultiMap<PackageRef,PackageRef>(
+ PackageRef.class, PackageRef.class,
true);
private final Packages classpathExports = new Packages();
private final Descriptors descriptors = new Descriptors();
private final List<Jar> classpath = list();
- private final Map<TypeRef, Clazz> classspace = map();
- private final Map<TypeRef, Clazz> importedClassesCache = map();
+ private final Map<TypeRef,Clazz> classspace = map();
+ private final Map<TypeRef,Clazz> importedClassesCache = map();
private boolean analyzed = false;
private boolean diagnostics = false;
private boolean inited = false;
+ final protected AnalyzerMessages msgs = ReporterMessages.base(this,
+ AnalyzerMessages.class);
public Analyzer(Processor parent) {
super(parent);
}
- public Analyzer() {
- }
+ public Analyzer() {}
/**
* Specifically for Maven
*
- * @param properties the properties
+ * @param properties
+ * the properties
*/
public static Properties getManifest(File dirOrJar) throws Exception {
@@ -280,7 +282,6 @@
}
/**
- *
* @return
*/
boolean isResourceOnly() {
@@ -306,9 +307,8 @@
boolean noExtraHeaders = "true".equalsIgnoreCase(getProperty(NOEXTRAHEADERS));
if (!noExtraHeaders) {
- main.putValue(CREATED_BY,
- System.getProperty("java.version") + " (" + System.getProperty("java.vendor")
- + ")");
+ main.putValue(CREATED_BY, System.getProperty("java.version") + " (" + System.getProperty("java.vendor")
+ + ")");
main.putValue(TOOL, "Bnd-" + getBndVersion());
main.putValue(BND_LASTMODIFIED, "" + System.currentTimeMillis());
}
@@ -323,8 +323,7 @@
// Remove all the Java packages from the imports
if (!imports.isEmpty()) {
main.putValue(IMPORT_PACKAGE, printClauses(imports));
- }
- else {
+ } else {
main.remove(IMPORT_PACKAGE);
}
@@ -360,8 +359,7 @@
continue;
}
- if (header.equals(BUNDLE_CLASSPATH) || header.equals(EXPORT_PACKAGE)
- || header.equals(IMPORT_PACKAGE))
+ if (header.equals(BUNDLE_CLASSPATH) || header.equals(EXPORT_PACKAGE) || header.equals(IMPORT_PACKAGE))
continue;
if (header.equalsIgnoreCase("Name")) {
@@ -374,14 +372,12 @@
if (value != null && main.getValue(header) == null) {
if (value.trim().length() == 0)
main.remove(header);
+ else if (value.trim().equals(EMPTY_HEADER))
+ main.putValue(header, "");
else
- if (value.trim().equals(EMPTY_HEADER))
- main.putValue(header, "");
- else
- main.putValue(header, value);
+ main.putValue(header, value);
}
- }
- else {
+ } else {
// TODO should we report?
}
}
@@ -424,9 +420,7 @@
/**
* Parse the namesection as instructions and then match them against the
- * current set of resources
- *
- * For example:
+ * current set of resources For example:
*
* <pre>
* -namesection: *;baz=true, abc/def/bar/X.class=3
@@ -435,7 +429,6 @@
* The raw value of {@link Constants#NAMESECTION} is used but the values of
* the attributes are replaced where @ is set to the resource name. This
* allows macro to operate on the resource
- *
*/
private void doNamesection(Jar dot, Manifest manifest) {
@@ -451,7 +444,7 @@
// to the manifest for the given resource name. Then add all
// attributes from the instruction to that name section.
//
- for (Map.Entry<Instruction, Attrs> instr : instructions.entrySet()) {
+ for (Map.Entry<Instruction,Attrs> instr : instructions.entrySet()) {
boolean matched = false;
// For each instruction
@@ -480,7 +473,7 @@
// name section
//
- for (Map.Entry<String, String> property : instr.getValue().entrySet()) {
+ for (Map.Entry<String,String> property : instr.getValue().entrySet()) {
setProperty("@", path);
try {
String processed = getReplacer().process(property.getValue());
@@ -496,8 +489,7 @@
}
if (!matched && resources.size() > 0)
- warning("The instruction %s in %s did not match any resources", instr.getKey(),
- NAMESECTION);
+ warning("The instruction %s in %s did not match any resources", instr.getKey(), NAMESECTION);
}
}
@@ -532,10 +524,8 @@
manifest.getEntries().put(path, attrs);
}
attrs.putValue(name, getProperty(header));
- }
- else {
- warning("Invalid header (starts with @ but does not seem to be for the Name section): %s",
- header);
+ } else {
+ warning("Invalid header (starts with @ but does not seem to be for the Name section): %s", header);
}
}
@@ -554,13 +544,11 @@
String projectName = getBase().getName();
if (value == null || value.equals("bnd.bnd")) {
value = projectName;
+ } else if (value.endsWith(".bnd")) {
+ value = value.substring(0, value.length() - 4);
+ if (!value.startsWith(getBase().getName()))
+ value = projectName + "." + value;
}
- else
- if (value.endsWith(".bnd")) {
- value = value.substring(0, value.length() - 4);
- if (!value.startsWith(getBase().getName()))
- value = projectName + "." + value;
- }
}
if (value == null)
@@ -579,13 +567,14 @@
/**
* Calculate an export header solely based on the contents of a JAR file
*
- * @param bundle The jar file to analyze
+ * @param bundle
+ * The jar file to analyze
* @return
*/
public String calculateExportsFromContents(Jar bundle) {
String ddel = "";
StringBuilder sb = new StringBuilder();
- Map<String, Map<String, Resource>> map = bundle.getDirectories();
+ Map<String,Map<String,Resource>> map = bundle.getDirectories();
for (Iterator<String> i = map.keySet().iterator(); i.hasNext();) {
String directory = i.next();
if (directory.equals("META-INF") || directory.startsWith("META-INF/"))
@@ -644,7 +633,7 @@
return unreachable;
}
- public MultiMap<PackageRef, PackageRef> getUses() {
+ public MultiMap<PackageRef,PackageRef> getUses() {
return uses;
}
@@ -663,6 +652,7 @@
return Long.parseLong(time);
}
catch (Exception e) {
+ // Ignore
}
return 0;
}
@@ -693,7 +683,8 @@
* Merge the existing manifest with the instructions but do not override
* existing properties.
*
- * @param manifest The manifest to merge with
+ * @param manifest
+ * The manifest to merge with
* @throws IOException
*/
public void mergeManifest(Manifest manifest) throws IOException {
@@ -729,8 +720,7 @@
if (classpath[i].exists()) {
Jar current = new Jar(classpath[i]);
list.add(current);
- }
- else {
+ } else {
error("Missing file on classpath: %s", classpath[i]);
}
}
@@ -799,8 +789,10 @@
* Try to get a Jar from a file name/path or a url, or in last resort from
* the classpath name part of their files.
*
- * @param name URL or filename relative to the base
- * @param from Message identifying the caller for errors
+ * @param name
+ * URL or filename relative to the base
+ * @param from
+ * Message identifying the caller for errors
* @return null or a Jar with the contents for the name
*/
Jar getJarFromName(String name, String from) {
@@ -856,15 +848,13 @@
}
/**
- *
* @param manifests
* @throws Exception
*/
- private void merge(Manifest result, Manifest old) throws IOException {
+ private void merge(Manifest result, Manifest old) {
if (old != null) {
- for (Iterator<Map.Entry<Object, Object>> e = old.getMainAttributes().entrySet()
- .iterator(); e.hasNext();) {
- Map.Entry<Object, Object> entry = e.next();
+ for (Iterator<Map.Entry<Object,Object>> e = old.getMainAttributes().entrySet().iterator(); e.hasNext();) {
+ Map.Entry<Object,Object> entry = e.next();
Attributes.Name name = (Attributes.Name) entry.getKey();
String value = (String) entry.getValue();
if (name.toString().equalsIgnoreCase("Created-By"))
@@ -874,11 +864,10 @@
}
// do not overwrite existing entries
- Map<String, Attributes> oldEntries = old.getEntries();
- Map<String, Attributes> newEntries = result.getEntries();
- for (Iterator<Map.Entry<String, Attributes>> e = oldEntries.entrySet().iterator(); e
- .hasNext();) {
- Map.Entry<String, Attributes> entry = e.next();
+ Map<String,Attributes> oldEntries = old.getEntries();
+ Map<String,Attributes> newEntries = result.getEntries();
+ for (Iterator<Map.Entry<String,Attributes>> e = oldEntries.entrySet().iterator(); e.hasNext();) {
+ Map.Entry<String,Attributes> entry = e.next();
if (!newEntries.containsKey(entry.getKey())) {
newEntries.put(entry.getKey(), entry.getValue());
}
@@ -891,7 +880,8 @@
* not using an invalid case. We do allow this to set headers that should
* not be processed by us but should be used by the framework.
*
- * @param properties Properties to verify.
+ * @param properties
+ * Properties to verify.
*/
void verifyManifestHeadersCase(Properties properties) {
@@ -910,26 +900,21 @@
/**
* We will add all exports to the imports unless there is a -noimport
* directive specified on an export. This directive is skipped for the
- * manifest.
- *
- * We also remove any version parameter so that augmentImports can do the
- * version policy.
- *
- * The following method is really tricky and evolved over time. Coming from
- * the original background of OSGi, it was a weird idea for me to have a
- * public package that should not be substitutable. I was so much convinced
- * that this was the right rule that I rücksichtlos imported them all. Alas,
- * the real world was more subtle than that. It turns out that it is not a
- * good idea to always import. First, there must be a need to import, i.e.
- * there must be a contained package that refers to the exported package for
- * it to make use importing that package. Second, if an exported package
- * refers to an internal package than it should not be imported.
- *
- * Additionally, it is necessary to treat the exports in groups. If an
- * exported package refers to another exported packages than it must be in
- * the same group. A framework can only substitute exports for imports for
- * the whole of such a group. WHY????? Not clear anymore ...
- *
+ * manifest. We also remove any version parameter so that augmentImports can
+ * do the version policy. The following method is really tricky and evolved
+ * over time. Coming from the original background of OSGi, it was a weird
+ * idea for me to have a public package that should not be substitutable. I
+ * was so much convinced that this was the right rule that I rücksichtlos
+ * imported them all. Alas, the real world was more subtle than that. It
+ * turns out that it is not a good idea to always import. First, there must
+ * be a need to import, i.e. there must be a contained package that refers
+ * to the exported package for it to make use importing that package.
+ * Second, if an exported package refers to an internal package than it
+ * should not be imported. Additionally, it is necessary to treat the
+ * exports in groups. If an exported package refers to another exported
+ * packages than it must be in the same group. A framework can only
+ * substitute exports for imports for the whole of such a group. WHY?????
+ * Not clear anymore ...
*/
Packages doExportsToImports(Packages exports) {
@@ -1003,7 +988,7 @@
public boolean referred(PackageRef packageName) {
// return true;
- for (Map.Entry<PackageRef, List<PackageRef>> contained : uses.entrySet()) {
+ for (Map.Entry<PackageRef,List<PackageRef>> contained : uses.entrySet()) {
if (!contained.getKey().equals(packageName)) {
if (contained.getValue().contains(packageName))
return true;
@@ -1013,7 +998,6 @@
}
/**
- *
* @param jar
*/
private void getExternalExports(Jar jar, Packages classpathExports) {
@@ -1022,7 +1006,7 @@
if (m != null) {
Domain domain = Domain.domain(m);
Parameters exported = domain.getExportPackage();
- for (Entry<String, Attrs> e : exported.entrySet()) {
+ for (Entry<String,Attrs> e : exported.entrySet()) {
PackageRef ref = getPackageRef(e.getKey());
if (!classpathExports.containsKey(ref)) {
// TODO e.getValue().put(SOURCE_DIRECTIVE,
@@ -1055,8 +1039,7 @@
setProperty(CURRENT_PACKAGE, packageName);
try {
Attrs importAttributes = imports.get(packageRef);
- Attrs exportAttributes = exports.get(packageRef,
- classpathExports.get(packageRef, new Attrs()));
+ Attrs exportAttributes = exports.get(packageRef, classpathExports.get(packageRef, new Attrs()));
String exportVersion = exportAttributes.getVersion();
String importRange = importAttributes.getVersion();
@@ -1064,8 +1047,7 @@
if (exportVersion == null) {
// TODO Should check if the source is from a bundle.
- }
- else {
+ } else {
//
// Version Policy - Import version substitution. We
@@ -1076,8 +1058,7 @@
//
boolean provider = isTrue(importAttributes.get(PROVIDE_DIRECTIVE))
- || isTrue(exportAttributes.get(PROVIDE_DIRECTIVE))
- || provided.contains(packageRef);
+ || isTrue(exportAttributes.get(PROVIDE_DIRECTIVE)) || provided.contains(packageRef);
exportVersion = cleanupVersion(exportVersion);
@@ -1087,8 +1068,7 @@
if (importRange != null) {
importRange = cleanupVersion(importRange);
importRange = getReplacer().process(importRange);
- }
- else
+ } else
importRange = getVersionPolicy(provider);
}
@@ -1180,7 +1160,7 @@
if (exporterAttributes == null)
continue;
- for (Map.Entry<String, String> entry : exporterAttributes.entrySet()) {
+ for (Map.Entry<String,String> entry : exporterAttributes.entrySet()) {
String key = entry.getKey();
if (key.equalsIgnoreCase(SPECIFICATION_VERSION))
key = VERSION_ATTRIBUTE;
@@ -1202,9 +1182,7 @@
}
/**
- * Fixup Attributes
- *
- * Execute any macros on an export and
+ * Fixup Attributes Execute any macros on an export and
*/
void fixupAttributes(Attrs attributes) {
@@ -1236,7 +1214,7 @@
}
// Remove any ! valued attributes
- for (Iterator<Entry<String, String>> i = attributes.entrySet().iterator(); i.hasNext();) {
+ for (Iterator<Entry<String,String>> i = attributes.entrySet().iterator(); i.hasNext();) {
String v = i.next().getValue();
if (v.equals("!"))
i.remove();
@@ -1246,8 +1224,10 @@
/**
* Calculate a version from a version policy.
*
- * @param version The actual exported version
- * @param impl true for implementations and false for clients
+ * @param version
+ * The actual exported version
+ * @param impl
+ * true for implementations and false for clients
*/
String calculateVersionRange(String version, boolean impl) {
@@ -1267,7 +1247,7 @@
* @param uses
* @throws MojoExecutionException
*/
- void doUses(Packages exports, MultiMap<PackageRef, PackageRef> uses, Packages imports) {
+ void doUses(Packages exports, MultiMap<PackageRef,PackageRef> uses, Packages imports) {
if ("true".equalsIgnoreCase(getProperty(NOUSES)))
return;
@@ -1291,8 +1271,8 @@
* @param uses
* @param imports
*/
- protected void doUses(PackageRef packageRef, Packages exports,
- MultiMap<PackageRef, PackageRef> uses, Packages imports) {
+ protected void doUses(PackageRef packageRef, Packages exports, MultiMap<PackageRef,PackageRef> uses,
+ Packages imports) {
Attrs clause = exports.get(packageRef);
// Check if someone already set the uses: directive
@@ -1328,12 +1308,10 @@
setProperty(CURRENT_USES, sb.toString());
override = getReplacer().process(override);
unsetProperty(CURRENT_USES);
- }
- else
+ } else
// This is for backward compatibility 0.0.287
// can be deprecated over time
- override = override.replaceAll(USES_USES, Matcher.quoteReplacement(sb.toString()))
- .trim();
+ override = override.replaceAll(USES_USES, Matcher.quoteReplacement(sb.toString())).trim();
if (override.endsWith(","))
override = override.substring(0, override.length() - 1);
@@ -1374,8 +1352,7 @@
* @param value
* @throws Exception
*/
- void setPackageInfo(PackageRef packageRef, Resource r, Packages classpathExports)
- throws Exception {
+ void setPackageInfo(PackageRef packageRef, Resource r, Packages classpathExports) throws Exception {
if (r == null)
return;
@@ -1418,18 +1395,15 @@
out.println("Classpath used");
for (Jar jar : getClasspath()) {
out.printf("File : %s%n", jar.getSource());
- out.printf("File abs path : %s%n", jar.getSource()
- .getAbsolutePath());
+ out.printf("File abs path : %s%n", jar.getSource().getAbsolutePath());
out.printf("Name : %s%n", jar.getName());
- Map<String, Map<String, Resource>> dirs = jar.getDirectories();
- for (Map.Entry<String, Map<String, Resource>> entry : dirs.entrySet()) {
- Map<String, Resource> dir = entry.getValue();
+ Map<String,Map<String,Resource>> dirs = jar.getDirectories();
+ for (Map.Entry<String,Map<String,Resource>> entry : dirs.entrySet()) {
+ Map<String,Resource> dir = entry.getValue();
String name = entry.getKey().replace('/', '.');
if (dir != null) {
- out.printf(" %-30s %d%n", name,
- dir.size());
- }
- else {
+ out.printf(" %-30s %d%n", name, dir.size());
+ } else {
out.printf(" %-30s <<empty>>%n", name);
}
}
@@ -1449,9 +1423,8 @@
/**
* Findpath looks through the contents of the JAR and finds paths that end
- * with the given regular expression
- *
- * ${findpath (; reg-expr (; replacement)? )? }
+ * with the given regular expression ${findpath (; reg-expr (; replacement)?
+ * )? }
*
* @param args
* @return
@@ -1466,8 +1439,8 @@
String findPath(String name, String[] args, boolean fullPathName) {
if (args.length > 3) {
- warning("Invalid nr of arguments to " + name + " " + Arrays.asList(args)
- + ", syntax: ${" + name + " (; reg-expr (; replacement)? )? }");
+ warning("Invalid nr of arguments to " + name + " " + Arrays.asList(args) + ", syntax: ${" + name
+ + " (; reg-expr (; replacement)? )? }");
return null;
}
@@ -1507,9 +1480,9 @@
return sb.toString();
}
- public void putAll(Map<String, String> additional, boolean force) {
- for (Iterator<Map.Entry<String, String>> i = additional.entrySet().iterator(); i.hasNext();) {
- Map.Entry<String, String> entry = i.next();
+ public void putAll(Map<String,String> additional, boolean force) {
+ for (Iterator<Map.Entry<String,String>> i = additional.entrySet().iterator(); i.hasNext();) {
+ Map.Entry<String,String> entry = i.next();
if (force || getProperties().get(entry.getKey()) == null)
setProperty(entry.getKey(), entry.getValue());
}
@@ -1544,15 +1517,12 @@
for (Object jar : jars) {
if (jar instanceof Jar)
addClasspath((Jar) jar);
+ else if (jar instanceof File)
+ addClasspath((File) jar);
+ else if (jar instanceof String)
+ addClasspath(getFile((String) jar));
else
- if (jar instanceof File)
- addClasspath((File) jar);
- else
- if (jar instanceof String)
- addClasspath(getFile((String) jar));
- else
- error("Cannot convert to JAR to add to classpath %s. Not a File, Jar, or String",
- jar);
+ error("Cannot convert to JAR to add to classpath %s. Not a File, Jar, or String", jar);
}
}
@@ -1577,8 +1547,7 @@
if (bcp.isEmpty()) {
analyzeJar(dot, "", true);
- }
- else {
+ } else {
boolean okToIncludeDirs = true;
for (String path : bcp.keySet()) {
@@ -1613,8 +1582,7 @@
catch (Exception e) {
warning("Invalid bundle classpath entry: " + path + " " + e);
}
- }
- else {
+ } else {
if (dot.getDirectories().containsKey(path)) {
// if directories are used, we should not have dot as we
// would have the classes in these directories on the
@@ -1623,8 +1591,7 @@
warning("Bundle-ClassPath uses a directory '%s' as well as '.'. This means bnd does not know if a directory is a package.",
path, path);
analyzeJar(dot, Processor.appendPath(path) + "/", true);
- }
- else {
+ } else {
if (!"optional".equals(info.get(RESOLUTION_DIRECTIVE)))
warning("No sub JAR or directory " + path);
}
@@ -1646,7 +1613,7 @@
* @throws IOException
*/
private boolean analyzeJar(Jar jar, String prefix, boolean okToIncludeDirs) throws Exception {
- Map<String, Clazz> mismatched = new HashMap<String, Clazz>();
+ Map<String,Clazz> mismatched = new HashMap<String,Clazz>();
next: for (String path : jar.getResources().keySet()) {
if (path.startsWith(prefix)) {
@@ -1668,8 +1635,7 @@
// we found a class since the bcp has a tendency
// to overlap
if (!packageRef.isMetaData()) {
- Resource pinfo = jar.getResource(prefix + packageRef.getPath()
- + "/packageinfo");
+ Resource pinfo = jar.getResource(prefix + packageRef.getPath() + "/packageinfo");
setPackageInfo(packageRef, pinfo, classpathExports);
}
}
@@ -1690,8 +1656,7 @@
// package-info can contain an Export annotation
info = new Attrs();
parsePackageInfoClass(clazz, info);
- }
- else {
+ } else {
// Otherwise we just parse it simply
clazz.parseClassFile();
}
@@ -1712,16 +1677,14 @@
// warning
if (okToIncludeDirs) // assume already reported
mismatched.put(clazz.getAbsolutePath(), clazz);
- }
- else {
+ } else {
classspace.put(clazz.getClassName(), clazz);
PackageRef packageRef = clazz.getClassName().getPackageRef();
if (!contained.containsKey(packageRef)) {
contained.put(packageRef);
if (!packageRef.isMetaData()) {
- Resource pinfo = jar.getResource(prefix + packageRef.getPath()
- + "/packageinfo");
+ Resource pinfo = jar.getResource(prefix + packageRef.getPath() + "/packageinfo");
setPackageInfo(packageRef, pinfo, classpathExports);
}
}
@@ -1767,92 +1730,87 @@
if (Verifier.VERSION.matcher(version).matches())
info.put(VERSION_ATTRIBUTE, version);
else
- error("Export annotation in %s has invalid version info: %s",
- clazz, version);
+ error("Export annotation in %s has invalid version info: %s", clazz, version);
}
- }
- else {
+ } else {
// Verify this matches with packageinfo
String presentVersion = info.get(VERSION_ATTRIBUTE);
try {
Version av = new Version(presentVersion);
Version bv = new Version(version);
if (!av.equals(bv)) {
- error("Version from annotation for %s differs with packageinfo or Manifest",
- clazz.getClassName().getFQN());
+ error("Version from annotation for %s differs with packageinfo or Manifest", clazz
+ .getClassName().getFQN());
}
}
catch (Exception e) {
// Ignore
}
}
- }
- else
- if (name.equals(Export.class.getName())) {
+ } else if (name.equals(Export.class.getName())) {
- // Check mandatory attributes
- Attrs attrs = doAttrbutes((Object[]) a.get(Export.MANDATORY), clazz,
- getReplacer());
- if (!attrs.isEmpty()) {
- info.putAll(attrs);
- info.put(MANDATORY_DIRECTIVE, Processor.join(attrs.keySet()));
- }
+ // Check mandatory attributes
+ Attrs attrs = doAttrbutes((Object[]) a.get(Export.MANDATORY), clazz, getReplacer());
+ if (!attrs.isEmpty()) {
+ info.putAll(attrs);
+ info.put(MANDATORY_DIRECTIVE, Processor.join(attrs.keySet()));
+ }
- // Check optional attributes
- attrs = doAttrbutes((Object[]) a.get(Export.OPTIONAL), clazz, getReplacer());
- if (!attrs.isEmpty()) {
- info.putAll(attrs);
- }
+ // Check optional attributes
+ attrs = doAttrbutes((Object[]) a.get(Export.OPTIONAL), clazz, getReplacer());
+ if (!attrs.isEmpty()) {
+ info.putAll(attrs);
+ }
- // Check Included classes
- Object[] included = a.get(Export.INCLUDE);
- if (included != null && included.length > 0) {
- StringBuilder sb = new StringBuilder();
- String del = "";
- for (Object i : included) {
- Matcher m = OBJECT_REFERENCE.matcher((String) i);
- if (m.matches()) {
- sb.append(del);
- sb.append(m.group(2));
- del = ",";
- }
- }
- info.put(INCLUDE_DIRECTIVE, sb.toString());
- }
-
- // Check Excluded classes
- Object[] excluded = a.get(Export.EXCLUDE);
- if (excluded != null && excluded.length > 0) {
- StringBuilder sb = new StringBuilder();
- String del = "";
- for (Object i : excluded) {
- Matcher m = OBJECT_REFERENCE.matcher((String) i);
- if (m.matches()) {
- sb.append(del);
- sb.append(m.group(2));
- del = ",";
- }
- }
- info.put(EXCLUDE_DIRECTIVE, sb.toString());
- }
-
- // Check Uses
- Object[] uses = a.get(Export.USES);
- if (uses != null && uses.length > 0) {
- String old = info.get(USES_DIRECTIVE);
- if (old == null)
- old = "";
- StringBuilder sb = new StringBuilder(old);
- String del = sb.length() == 0 ? "" : ",";
-
- for (Object use : uses) {
+ // Check Included classes
+ Object[] included = a.get(Export.INCLUDE);
+ if (included != null && included.length > 0) {
+ StringBuilder sb = new StringBuilder();
+ String del = "";
+ for (Object i : included) {
+ Matcher m = OBJECT_REFERENCE.matcher((String) i);
+ if (m.matches()) {
sb.append(del);
- sb.append(use);
+ sb.append(m.group(2));
del = ",";
}
- info.put(USES_DIRECTIVE, sb.toString());
}
+ info.put(INCLUDE_DIRECTIVE, sb.toString());
}
+
+ // Check Excluded classes
+ Object[] excluded = a.get(Export.EXCLUDE);
+ if (excluded != null && excluded.length > 0) {
+ StringBuilder sb = new StringBuilder();
+ String del = "";
+ for (Object i : excluded) {
+ Matcher m = OBJECT_REFERENCE.matcher((String) i);
+ if (m.matches()) {
+ sb.append(del);
+ sb.append(m.group(2));
+ del = ",";
+ }
+ }
+ info.put(EXCLUDE_DIRECTIVE, sb.toString());
+ }
+
+ // Check Uses
+ Object[] uses = a.get(Export.USES);
+ if (uses != null && uses.length > 0) {
+ String old = info.get(USES_DIRECTIVE);
+ if (old == null)
+ old = "";
+ StringBuilder sb = new StringBuilder(old);
+ String del = sb.length() == 0 ? "" : ",";
+
+ for (Object use : uses) {
+ sb.append(del);
+ sb.append(use);
+ del = ",";
+ }
+ info.put(USES_DIRECTIVE, sb.toString());
+ }
+ }
}
});
@@ -1866,14 +1824,11 @@
* @param VERSION_STRING
* @return
*/
- static Pattern fuzzyVersion = Pattern
- .compile(
- "(\\d+)(\\.(\\d+)(\\.(\\d+))?)?([^a-zA-Z0-9](.*))?",
- Pattern.DOTALL);
- static Pattern fuzzyVersionRange = Pattern
- .compile(
- "(\\(|\\[)\\s*([-\\da-zA-Z.]+)\\s*,\\s*([-\\da-zA-Z.]+)\\s*(\\]|\\))",
- Pattern.DOTALL);
+ static Pattern fuzzyVersion = Pattern.compile("(\\d+)(\\.(\\d+)(\\.(\\d+))?)?([^a-zA-Z0-9](.*))?",
+ Pattern.DOTALL);
+ static Pattern fuzzyVersionRange = Pattern.compile(
+ "(\\(|\\[)\\s*([-\\da-zA-Z.]+)\\s*,\\s*([-\\da-zA-Z.]+)\\s*(\\]|\\))",
+ Pattern.DOTALL);
static Pattern fuzzyModifier = Pattern.compile("(\\d+[.-])*(.*)", Pattern.DOTALL);
static Pattern nummeric = Pattern.compile("\\d*");
@@ -1893,49 +1848,47 @@
String suffix = m.group(4);
return prefix + cleanupVersion(first) + "," + cleanupVersion(last) + suffix;
}
- else {
- m = fuzzyVersion.matcher(version);
- if (m.matches()) {
- StringBuilder result = new StringBuilder();
- String major = removeLeadingZeroes(m.group(1));
- String minor = removeLeadingZeroes(m.group(3));
- String micro = removeLeadingZeroes(m.group(5));
- String qualifier = m.group(7);
- if (major != null) {
- result.append(major);
- if (minor != null) {
+ m = fuzzyVersion.matcher(version);
+ if (m.matches()) {
+ StringBuilder result = new StringBuilder();
+ String major = removeLeadingZeroes(m.group(1));
+ String minor = removeLeadingZeroes(m.group(3));
+ String micro = removeLeadingZeroes(m.group(5));
+ String qualifier = m.group(7);
+
+ if (major != null) {
+ result.append(major);
+ if (minor != null) {
+ result.append(".");
+ result.append(minor);
+ if (micro != null) {
result.append(".");
- result.append(minor);
- if (micro != null) {
- result.append(".");
- result.append(micro);
- if (qualifier != null) {
- result.append(".");
- cleanupModifier(result, qualifier);
- }
- }
- else
- if (qualifier != null) {
- result.append(".0.");
- cleanupModifier(result, qualifier);
- }
- }
- else
+ result.append(micro);
if (qualifier != null) {
- result.append(".0.0.");
+ result.append(".");
cleanupModifier(result, qualifier);
}
- return result.toString();
+ } else if (qualifier != null) {
+ result.append(".0.");
+ cleanupModifier(result, qualifier);
+ }
+ } else if (qualifier != null) {
+ result.append(".0.0.");
+ cleanupModifier(result, qualifier);
}
+ return result.toString();
}
}
return version;
}
private static String removeLeadingZeroes(String group) {
+ if (group == null)
+ return null;
+
int n = 0;
- while (group != null && n < group.length() - 1 && group.charAt(n) == '0')
+ while (n < group.length() - 1 && group.charAt(n) == '0')
n++;
if (n == 0)
return group;
@@ -1950,8 +1903,7 @@
for (int i = 0; i < modifier.length(); i++) {
char c = modifier.charAt(i);
- if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
- || c == '_' || c == '-')
+ if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || c == '-')
result.append(c);
}
}
@@ -1972,17 +1924,16 @@
return getProperty(VERSIONPOLICY, DEFAULT_PROVIDER_POLICY);
}
- else {
- String s = getProperty(CONSUMER_POLICY);
- if (s != null)
- return s;
+ String s = getProperty(CONSUMER_POLICY);
+ if (s != null)
+ return s;
- s = getProperty(VERSIONPOLICY_USES);
- if (s != null)
- return s;
+ s = getProperty(VERSIONPOLICY_USES);
+ if (s != null)
+ return s;
- return getProperty(VERSIONPOLICY, DEFAULT_CONSUMER_POLICY);
- }
+ return getProperty(VERSIONPOLICY, DEFAULT_CONSUMER_POLICY);
+
// String vp = implemented ? getProperty(VERSIONPOLICY_IMPL) :
// getProperty(VERSIONPOLICY_USES);
//
@@ -2019,24 +1970,21 @@
Set<Clazz> matched = new HashSet<Clazz>(classspace.values());
for (int i = 1; i < args.length; i++) {
if (args.length < i + 1)
- throw new IllegalArgumentException(
- "${classes} macro must have odd number of arguments. " + _classesHelp);
+ throw new IllegalArgumentException("${classes} macro must have odd number of arguments. "
+ + _classesHelp);
String typeName = args[i];
if (typeName.equalsIgnoreCase("extending"))
typeName = "extends";
- else
- if (typeName.equalsIgnoreCase("importing"))
- typeName = "imports";
- else
- if (typeName.equalsIgnoreCase("implementing"))
- typeName = "implements";
+ else if (typeName.equalsIgnoreCase("importing"))
+ typeName = "imports";
+ else if (typeName.equalsIgnoreCase("implementing"))
+ typeName = "implements";
Clazz.QUERY type = Clazz.QUERY.valueOf(typeName.toUpperCase());
if (type == null)
- throw new IllegalArgumentException("${classes} has invalid type: " + typeName
- + ". " + _classesHelp);
+ throw new IllegalArgumentException("${classes} has invalid type: " + typeName + ". " + _classesHelp);
Instruction instr = null;
if (Clazz.HAS_ARGUMENT.contains(type)) {
@@ -2058,9 +2006,7 @@
*/
public String _exporters(String args[]) throws Exception {
- Macro.verifyCommand(
- args,
- "${exporters;<packagename>}, returns the list of jars that export the given package",
+ Macro.verifyCommand(args, "${exporters;<packagename>}, returns the list of jars that export the given package",
null, 2, 2);
StringBuilder sb = new StringBuilder();
String del = "";
@@ -2074,14 +2020,15 @@
return sb.toString();
}
- public Map<TypeRef, Clazz> getClassspace() {
+ public Map<TypeRef,Clazz> getClassspace() {
return classspace;
}
/**
* Locate a resource on the class path.
*
- * @param path Path of the reosurce
+ * @param path
+ * Path of the reosurce
* @return A resource or <code>null</code>
*/
public Resource findResource(String path) {
@@ -2158,7 +2105,7 @@
if (require == null || require.isEmpty())
return;
- Hashtable<String, String> map = new Hashtable<String, String>();
+ Hashtable<String,String> map = new Hashtable<String,String>();
map.put(Constants.VERSION_FILTER, getBndVersion());
for (String filter : require.keySet()) {
@@ -2181,8 +2128,9 @@
static String _md5Help = "${md5;path}";
public String _md5(String args[]) throws Exception {
- Macro.verifyCommand(args, _md5Help,
- new Pattern[] {null, null, Pattern.compile("base64|hex")}, 2, 3);
+ Macro.verifyCommand(args, _md5Help, new Pattern[] {
+ null, null, Pattern.compile("base64|hex")
+ }, 2, 3);
Digester<MD5> digester = MD5.getDigester();
Resource r = dot.getResource(args[1]);
@@ -2193,8 +2141,8 @@
boolean hex = args.length > 2 && args[2].equals("hex");
if (hex)
return Hex.toHexString(digester.digest().digest());
- else
- return Base64.encodeBase64(digester.digest().digest());
+
+ return Base64.encodeBase64(digester.digest().digest());
}
/**
@@ -2204,8 +2152,9 @@
static String _sha1Help = "${sha1;path}";
public String _sha1(String args[]) throws Exception {
- Macro.verifyCommand(args, _sha1Help,
- new Pattern[] {null, null, Pattern.compile("base64|hex")}, 2, 3);
+ Macro.verifyCommand(args, _sha1Help, new Pattern[] {
+ null, null, Pattern.compile("base64|hex")
+ }, 2, 3);
Digester<SHA1> digester = SHA1.getDigester();
Resource r = dot.getResource(args[1]);
if (r == null)
@@ -2248,7 +2197,6 @@
* are ordered so that the instructor can define which pattern matches
* first. Attributes in the instructions override any attributes from the
* actual.<br/>
- *
* A pattern is a modified regexp so it looks like globbing. The * becomes a
* .* just like the ? becomes a .?. '.' are replaced with \\. Additionally,
* if the pattern starts with an exclamation mark, it will remove that
@@ -2263,10 +2211,10 @@
* </ul>
* Enough rope to hang the average developer I would say.
*
- *
- * @param instructions the instructions with patterns.
- * @param source the actual found packages, contains no duplicates
- *
+ * @param instructions
+ * the instructions with patterns.
+ * @param source
+ * the actual found packages, contains no duplicates
* @return Only the packages that were filtered by the given instructions
*/
@@ -2319,8 +2267,7 @@
// doing and inserted a literal. So
// we ignore any not matched literals
if (instruction.isLiteral()) {
- result.merge(getPackageRef(instruction.getLiteral()), true,
- instructions.get(instruction));
+ result.merge(getPackageRef(instruction.getLiteral()), true, instructions.get(instruction));
i.remove();
continue;
}
@@ -2379,7 +2326,8 @@
* Untitled-[n]
* </pre>
*
- * @param output may be null, otherwise a file path relative to base
+ * @param output
+ * may be null, otherwise a file path relative to base
*/
public File getOutputFile(String output) {
@@ -2394,16 +2342,14 @@
outputDir = outputFile;
else
return outputFile;
- }
- else
+ } else
outputDir = getBase();
if (getBundleSymbolicName() != null) {
String bsn = getBundleSymbolicName();
String version = getBundleVersion();
Version v = Version.parseVersion(version);
- String outputName = bsn + "-" + v.getWithoutQualifier()
- + Constants.DEFAULT_JAR_EXTENSION;
+ String outputName = bsn + "-" + v.getWithoutQualifier() + Constants.DEFAULT_JAR_EXTENSION;
return new File(outputDir, outputName);
}
@@ -2413,8 +2359,7 @@
return new File(outputDir, outputName);
}
- error("Cannot establish an output name from %s, nor bsn, nor source file name, using Untitled",
- output);
+ error("Cannot establish an output name from %s, nor bsn, nor source file name, using Untitled", output);
int n = 0;
File f = getFile(outputDir, "Untitled");
while (f.isFile()) {
@@ -2428,9 +2373,11 @@
* source file has the same path as the output. It will also only save if
* the file was modified or the force flag is true
*
- * @param output the output file, if null {@link #getOutputFile(String)} is
- * used.
- * @param force if it needs to be overwritten
+ * @param output
+ * the output file, if null {@link #getOutputFile(String)} is
+ * used.
+ * @param force
+ * if it needs to be overwritten
* @throws Exception
*/
@@ -2441,8 +2388,8 @@
Jar jar = getJar();
File source = jar.getSource();
- trace("check for modified build=%s file=%s, diff=%s", jar.lastModified(),
- output.lastModified(), jar.lastModified() - output.lastModified());
+ trace("check for modified build=%s file=%s, diff=%s", jar.lastModified(), output.lastModified(),
+ jar.lastModified() - output.lastModified());
if (!output.exists() || output.lastModified() <= jar.lastModified() || force) {
output.getParentFile().mkdirs();
@@ -2450,8 +2397,7 @@
File bak = new File(source.getParentFile(), source.getName() + ".bak");
if (!source.renameTo(bak)) {
error("Could not create backup file %s", bak);
- }
- else
+ } else
source.delete();
}
try {
@@ -2464,10 +2410,9 @@
}
return true;
}
- else {
- trace("Not modified %s", output);
- return false;
- }
+ trace("Not modified %s", output);
+ return false;
+
}
/**
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/AnalyzerMessages.java b/bundleplugin/src/main/java/aQute/lib/osgi/AnalyzerMessages.java
new file mode 100644
index 0000000..3efea0a
--- /dev/null
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/AnalyzerMessages.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) OSGi Alliance (2012). All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package aQute.lib.osgi;
+
+import aQute.libg.reporter.*;
+
+public interface AnalyzerMessages extends Messages {
+/**/
+}
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/Annotation.java b/bundleplugin/src/main/java/aQute/lib/osgi/Annotation.java
index 86f8caa..cafe0e3 100644
--- a/bundleplugin/src/main/java/aQute/lib/osgi/Annotation.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/Annotation.java
@@ -6,16 +6,16 @@
import aQute.bnd.annotation.metatype.*;
import aQute.lib.osgi.Descriptors.TypeRef;
-@SuppressWarnings("unchecked") public class Annotation {
+@SuppressWarnings("unchecked")
+public class Annotation {
TypeRef name;
- Map<String, Object> elements;
+ Map<String,Object> elements;
ElementType member;
RetentionPolicy policy;
- public Annotation(TypeRef name, Map<String, Object> elements, ElementType member,
- RetentionPolicy policy) {
+ public Annotation(TypeRef name, Map<String,Object> elements, ElementType member, RetentionPolicy policy) {
this.name = name;
- if ( elements == null)
+ if (elements == null)
this.elements = Collections.emptyMap();
else
this.elements = elements;
@@ -30,11 +30,11 @@
public ElementType getElementType() {
return member;
}
-
+
public RetentionPolicy getRetentionPolicy() {
return policy;
}
-
+
public String toString() {
return name + ":" + member + ":" + policy + ":" + elements;
}
@@ -56,19 +56,20 @@
public Set<String> keySet() {
if (elements == null)
return Collections.emptySet();
-
+
return elements.keySet();
}
+
public <T extends java.lang.annotation.Annotation> T getAnnotation() throws Exception {
String cname = name.getFQN();
Class<T> c = (Class<T>) getClass().getClassLoader().loadClass(cname);
return getAnnotation(c);
}
- public <T extends java.lang.annotation.Annotation> T getAnnotation(Class<T> c)
- throws Exception {
+
+ public <T extends java.lang.annotation.Annotation> T getAnnotation(Class<T> c) throws Exception {
String cname = name.getFQN();
- if ( ! c.getName().equals(cname))
+ if (!c.getName().equals(cname))
return null;
- return Configurable.createConfigurable(c, elements );
+ return Configurable.createConfigurable(c, elements);
}
}
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/Builder.java b/bundleplugin/src/main/java/aQute/lib/osgi/Builder.java
index 3126056..58d112d 100755
--- a/bundleplugin/src/main/java/aQute/lib/osgi/Builder.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/Builder.java
@@ -23,19 +23,14 @@
import aQute.libg.header.*;
/**
- * Include-Resource: ( [name '=' ] file )+
- *
- * Private-Package: package-decl ( ',' package-decl )*
- *
- * Export-Package: package-decl ( ',' package-decl )*
- *
+ * Include-Resource: ( [name '=' ] file )+ Private-Package: package-decl ( ','
+ * package-decl )* Export-Package: package-decl ( ',' package-decl )*
* Import-Package: package-decl ( ',' package-decl )*
*
* @version $Revision$
*/
public class Builder extends Analyzer {
- static Pattern IR_PATTERN = Pattern
- .compile("[{]?-?@?(?:[^=]+=)?\\s*([^}!]+).*");
+ static Pattern IR_PATTERN = Pattern.compile("[{]?-?@?(?:[^=]+=)?\\s*([^}!]+).*");
private final DiffPluginImpl differ = new DiffPluginImpl();
private Pattern xdoNotCopy = null;
private static final int SPLIT_MERGE_LAST = 1;
@@ -50,8 +45,7 @@
super(parent);
}
- public Builder() {
- }
+ public Builder() {}
public Jar build() throws Exception {
trace("build");
@@ -60,8 +54,7 @@
return null;
if (getProperty(CONDUIT) != null)
- error("Specified " + CONDUIT
- + " but calls build() instead of builds() (might be a programmer error");
+ error("Specified " + CONDUIT + " but calls build() instead of builds() (might be a programmer error");
Jar dot = new Jar("dot");
try {
@@ -77,6 +70,8 @@
doIncludeResources(dot);
doWab(dot);
+ doBndInfo(dot);
+
// Check if we override the calculation of the
// manifest. We still need to calculated it because
// we need to have analyzed the classpath.
@@ -95,8 +90,7 @@
catch (Exception e) {
error(MANIFEST + " while reading manifest file", e);
}
- }
- else {
+ } else {
error(MANIFEST + ", no such file " + mf);
}
}
@@ -133,6 +127,21 @@
}
/**
+ * Make sure any bnd.info files are properly processed
+ *
+ * @param jar
+ */
+
+ private void doBndInfo(Jar jar) {
+ for (Entry<String,Resource> e : jar.getResources().entrySet()) {
+ if (e.getKey().endsWith("/bnd.info")) {
+ PreprocessResource pp = new PreprocessResource(this, e.getValue());
+ e.setValue(pp);
+ }
+ }
+ }
+
+ /**
* Check if we need to calculate any checksums.
*
* @param dot
@@ -215,16 +224,14 @@
for (String part : parts) {
File sub = getFile(f.getParentFile(), part);
if (!sub.exists() || !sub.getParentFile().equals(f.getParentFile())) {
- warning("Invalid Class-Path entry %s in %s, must exist and must reside in same directory",
- sub, f);
- }
- else {
+ warning("Invalid Class-Path entry %s in %s, must exist and must reside in same directory", sub,
+ f);
+ } else {
addWabLib(dot, sub);
}
}
}
- }
- else {
+ } else {
error("WAB lib does not exist %s", f);
}
}
@@ -255,14 +262,11 @@
changedFile(f);
}
- protected void changedFile(File f) {
- }
+ protected void changedFile(File f) {}
/**
- * Sign the jar file.
- *
- * -sign : <alias> [ ';' 'password:=' <password> ] [ ';' 'keystore:='
- * <keystore> ] [ ';' 'sign-password:=' <pw> ] ( ',' ... )*
+ * Sign the jar file. -sign : <alias> [ ';' 'password:=' <password> ] [ ';'
+ * 'keystore:=' <keystore> ] [ ';' 'sign-password:=' <pw> ] ( ',' ... )*
*
* @return
*/
@@ -276,7 +280,7 @@
List<SignerPlugin> signers = getPlugins(SignerPlugin.class);
Parameters infos = parseHeader(signing);
- for (Entry<String, Attrs> entry : infos.entrySet()) {
+ for (Entry<String,Attrs> entry : infos.entrySet()) {
for (SignerPlugin signer : signers) {
signer.sign(this, entry.getKey());
}
@@ -303,7 +307,7 @@
addClose(jar);
for (PackageRef pref : referred) {
for (Jar cpe : getClasspath()) {
- Map<String, Resource> map = cpe.getDirectories().get(pref.getPath());
+ Map<String,Resource> map = cpe.getDirectories().get(pref.getPath());
if (map != null) {
jar.addDirectory(map, false);
break;
@@ -335,7 +339,7 @@
}
public void cleanupVersion(Packages packages, String defaultVersion) {
- for (Map.Entry<PackageRef, Attrs> entry : packages.entrySet()) {
+ for (Map.Entry<PackageRef,Attrs> entry : packages.entrySet()) {
Attrs attributes = entry.getValue();
String v = attributes.get(Constants.VERSION_ATTRIBUTE);
if (v == null && defaultVersion != null) {
@@ -343,8 +347,7 @@
v = defaultVersion;
if (isPedantic())
warning("Used bundle version %s for exported package %s", v, entry.getKey());
- }
- else {
+ } else {
if (isPedantic())
warning("No export version for exported package %s", entry.getKey());
}
@@ -369,8 +372,9 @@
String packagePath = packageRef.getPath();
boolean found = false;
- String[] fixed = {"packageinfo", "package.html", "module-info.java",
- "package-info.java"};
+ String[] fixed = {
+ "packageinfo", "package.html", "module-info.java", "package-info.java"
+ };
for (Iterator<File> i = getSourcePath().iterator(); i.hasNext();) {
File root = i.next();
@@ -401,8 +405,7 @@
Resource resource = jar.getResource(sourcePath);
if (resource != null) {
dot.putResource("OSGI-OPT/src/" + sourcePath, resource);
- }
- else {
+ } else {
resource = jar.getResource("OSGI-OPT/src/" + sourcePath);
if (resource != null) {
dot.putResource("OSGI-OPT/src/" + sourcePath, resource);
@@ -411,8 +414,7 @@
}
}
if (getSourcePath().isEmpty())
- warning("Including sources but " + SOURCEPATH
- + " does not contain any source directories ");
+ warning("Including sources but " + SOURCEPATH + " does not contain any source directories ");
// TODO copy from the jars where they came from
}
}
@@ -432,8 +434,7 @@
File f = getFile(file);
if (!f.isDirectory()) {
error("Adding a sourcepath that is not a directory: " + f);
- }
- else {
+ } else {
sourcePath.add(f);
}
}
@@ -451,13 +452,13 @@
getInfo(verifier);
}
- private void doExpand(Jar dot) throws IOException {
+ private void doExpand(Jar dot) {
// Build an index of the class path that we can then
// use destructively
- MultiMap<String, Jar> packages = new MultiMap<String, Jar>();
+ MultiMap<String,Jar> packages = new MultiMap<String,Jar>();
for (Jar srce : getClasspath()) {
- for (Entry<String, Map<String, Resource>> e : srce.getDirectories().entrySet()) {
+ for (Entry<String,Map<String,Resource>> e : srce.getDirectories().entrySet()) {
if (e.getValue() != null)
packages.add(e.getKey(), srce);
}
@@ -474,8 +475,7 @@
Set<Instruction> unused = doExpand(dot, packages, privateFilter);
if (!unused.isEmpty()) {
- warning("Unused Private-Package instructions, no such package(s) on the class path: %s",
- unused);
+ warning("Unused Private-Package instructions, no such package(s) on the class path: %s", unused);
}
}
@@ -500,10 +500,10 @@
* @param name
* @param instructions
*/
- private Set<Instruction> doExpand(Jar jar, MultiMap<String, Jar> index, Instructions filter) {
+ private Set<Instruction> doExpand(Jar jar, MultiMap<String,Jar> index, Instructions filter) {
Set<Instruction> unused = Create.set();
- for (Entry<Instruction, Attrs> e : filter.entrySet()) {
+ for (Entry<Instruction,Attrs> e : filter.entrySet()) {
Instruction instruction = e.getKey();
if (instruction.isDuplicate())
continue;
@@ -518,9 +518,8 @@
boolean used = false;
- for (Iterator<Entry<String, List<Jar>>> entry = index.entrySet().iterator(); entry
- .hasNext();) {
- Entry<String, List<Jar>> p = entry.next();
+ for (Iterator<Entry<String,List<Jar>>> entry = index.entrySet().iterator(); entry.hasNext();) {
+ Entry<String,List<Jar>> p = entry.next();
String directory = p.getKey();
PackageRef packageRef = getPackageRef(directory);
@@ -626,14 +625,9 @@
private void copy(Jar dest, Jar srce, String path, boolean overwrite) {
dest.copy(srce, path, overwrite);
- String key = path + "/bnd.info";
- Resource r = dest.getResource(key);
- if (r != null)
- dest.putResource(key, new PreprocessResource(this, r));
-
if (hasSources()) {
String srcPath = "OSGI-OPT/src/" + path;
- Map<String, Resource> srcContents = srce.getDirectories().get(srcPath);
+ Map<String,Resource> srcContents = srce.getDirectories().get(srcPath);
if (srcContents != null) {
dest.addDirectory(srcContents, overwrite);
}
@@ -680,16 +674,19 @@
/**
* Matches the instructions against a package.
*
- * @param instructions The list of instructions
- * @param pack The name of the package
- * @param unused The total list of patterns, matched patterns are removed
- * @param source The name of the source container, can be filtered upon with
- * the from: directive.
+ * @param instructions
+ * The list of instructions
+ * @param pack
+ * The name of the package
+ * @param unused
+ * The total list of patterns, matched patterns are removed
+ * @param source
+ * The name of the source container, can be filtered upon with
+ * the from: directive.
* @return
*/
- private Instruction matches(Instructions instructions, String pack, Set<Instruction> unused,
- String source) {
- for (Entry<Instruction, Attrs> entry : instructions.entrySet()) {
+ private Instruction matches(Instructions instructions, String pack, Set<Instruction> unused, String source) {
+ for (Entry<Instruction,Attrs> entry : instructions.entrySet()) {
Instruction pattern = entry.getKey();
// It is possible to filter on the source of the
@@ -728,8 +725,7 @@
includes = getProperty(INCLUDERESOURCE);
if (includes == null || includes.length() == 0)
includes = getProperty("Include-Resource");
- }
- else
+ } else
warning("Please use -includeresource instead of Bundle-Includes");
doIncludeResource(jar, includes);
@@ -741,15 +737,14 @@
doIncludeResource(jar, clauses);
}
- private void doIncludeResource(Jar jar, Parameters clauses) throws ZipException, IOException,
- Exception {
- for (Entry<String, Attrs> entry : clauses.entrySet()) {
+ private void doIncludeResource(Jar jar, Parameters clauses) throws ZipException, IOException, Exception {
+ for (Entry<String,Attrs> entry : clauses.entrySet()) {
doIncludeResource(jar, entry.getKey(), entry.getValue());
}
}
- private void doIncludeResource(Jar jar, String name, Map<String, String> extra)
- throws ZipException, IOException, Exception {
+ private void doIncludeResource(Jar jar, String name, Map<String,String> extra) throws ZipException, IOException,
+ Exception {
boolean preprocess = false;
boolean absentIsOk = false;
@@ -771,56 +766,47 @@
}
if (source.startsWith("@")) {
- extractFromJar(jar, source.substring(1), parts.length == 1 ? "" : destination,
- absentIsOk);
- }
- else
- if (extra.containsKey("cmd")) {
- doCommand(jar, source, destination, extra, preprocess, absentIsOk);
+ extractFromJar(jar, source.substring(1), parts.length == 1 ? "" : destination, absentIsOk);
+ } else if (extra.containsKey("cmd")) {
+ doCommand(jar, source, destination, extra, preprocess, absentIsOk);
+ } else if (extra.containsKey("literal")) {
+ String literal = extra.get("literal");
+ Resource r = new EmbeddedResource(literal.getBytes("UTF-8"), 0);
+ String x = extra.get("extra");
+ if (x != null)
+ r.setExtra(x);
+ jar.putResource(name, r);
+ } else {
+ File sourceFile;
+ String destinationPath;
+
+ sourceFile = getFile(source);
+ if (parts.length == 1) {
+ // Directories should be copied to the root
+ // but files to their file name ...
+ if (sourceFile.isDirectory())
+ destinationPath = "";
+ else
+ destinationPath = sourceFile.getName();
+ } else {
+ destinationPath = parts[0];
}
- else
- if (extra.containsKey("literal")) {
- String literal = extra.get("literal");
- Resource r = new EmbeddedResource(literal.getBytes("UTF-8"), 0);
- String x = extra.get("extra");
- if (x != null)
- r.setExtra(x);
- jar.putResource(name, r);
- }
- else {
- File sourceFile;
- String destinationPath;
+ // Handle directories
+ if (sourceFile.isDirectory()) {
+ destinationPath = doResourceDirectory(jar, extra, preprocess, sourceFile, destinationPath);
+ return;
+ }
- sourceFile = getFile(source);
- if (parts.length == 1) {
- // Directories should be copied to the root
- // but files to their file name ...
- if (sourceFile.isDirectory())
- destinationPath = "";
- else
- destinationPath = sourceFile.getName();
- }
- else {
- destinationPath = parts[0];
- }
- // Handle directories
- if (sourceFile.isDirectory()) {
- destinationPath = doResourceDirectory(jar, extra, preprocess, sourceFile,
- destinationPath);
- return;
- }
+ // destinationPath = checkDestinationPath(destinationPath);
- // destinationPath = checkDestinationPath(destinationPath);
+ if (!sourceFile.exists()) {
+ if (absentIsOk)
+ return;
- if (!sourceFile.exists()) {
- if (absentIsOk)
- return;
-
- noSuchFile(jar, name, extra, source, destinationPath);
- }
- else
- copy(jar, destinationPath, sourceFile, preprocess, extra);
- }
+ noSuchFile(jar, name, extra, source, destinationPath);
+ } else
+ copy(jar, destinationPath, sourceFile, preprocess, extra);
+ }
}
/**
@@ -831,13 +817,10 @@
* {@link Macro#_lsa(String[])} or {@link Macro#_lsb(String[])} macro. The
* repetition will repeat the given command for each item. The @} macro can
* be used to replace the current item. If no {@code for} is given, the
- * source is used as the only item.
- *
- * If the destination contains a macro, each iteration will create a new
- * file, otherwise the destination name is used.
- *
- * The execution of the command is delayed until the JAR is actually written
- * to the file system for performance reasons.
+ * source is used as the only item. If the destination contains a macro,
+ * each iteration will create a new file, otherwise the destination name is
+ * used. The execution of the command is delayed until the JAR is actually
+ * written to the file system for performance reasons.
*
* @param jar
* @param source
@@ -846,8 +829,8 @@
* @param preprocess
* @param absentIsOk
*/
- private void doCommand(Jar jar, String source, String destination, Map<String, String> extra,
- boolean preprocess, boolean absentIsOk) {
+ private void doCommand(Jar jar, String source, String destination, Map<String,String> extra, boolean preprocess,
+ boolean absentIsOk) {
String repeat = extra.get("for"); // TODO constant
if (repeat == null)
repeat = source;
@@ -857,10 +840,9 @@
for (String required : requires) {
File file = getFile(required);
if (!file.isFile()) {
- error("Include-Resource.cmd for %s, requires %s, but no such file %s", source,
- required, file.getAbsoluteFile());
- }
- else
+ error("Include-Resource.cmd for %s, requires %s, but no such file %s", source, required,
+ file.getAbsoluteFile());
+ } else
lastModified = Math.max(lastModified, file.lastModified());
}
@@ -874,7 +856,7 @@
cr = new CombinedResource();
}
trace("last modified requires %s", lastModified);
-
+
for (String item : items) {
setProperty("@", item);
try {
@@ -883,7 +865,7 @@
File file = getFile(item);
Resource r = new CommandResource(command, this, Math.max(lastModified,
- file.exists() ? file.lastModified():0L));
+ file.exists() ? file.lastModified() : 0L));
if (preprocess)
r = new PreprocessResource(this, r);
@@ -897,15 +879,15 @@
unsetProperty("@");
}
}
-
+
// Add last so the correct modification date is used
// to update the modified time.
- if ( cr != null)
+ if (cr != null)
jar.putResource(destination, cr);
}
- private String doResourceDirectory(Jar jar, Map<String, String> extra, boolean preprocess,
- File sourceFile, String destinationPath) throws Exception {
+ private String doResourceDirectory(Jar jar, Map<String,String> extra, boolean preprocess, File sourceFile,
+ String destinationPath) throws Exception {
String filter = extra.get("filter:");
boolean flatten = isTrue(extra.get("flatten:"));
boolean recursive = true;
@@ -917,22 +899,21 @@
Instruction.Filter iFilter = null;
if (filter != null) {
iFilter = new Instruction.Filter(new Instruction(filter), recursive, getDoNotCopy());
- }
- else {
+ } else {
iFilter = new Instruction.Filter(null, recursive, getDoNotCopy());
}
- Map<String, File> files = newMap();
+ Map<String,File> files = newMap();
resolveFiles(sourceFile, iFilter, recursive, destinationPath, files, flatten);
- for (Map.Entry<String, File> entry : files.entrySet()) {
+ for (Map.Entry<String,File> entry : files.entrySet()) {
copy(jar, entry.getKey(), entry.getValue(), preprocess, extra);
}
return destinationPath;
}
- private void resolveFiles(File dir, FileFilter filter, boolean recursive, String path,
- Map<String, File> files, boolean flatten) {
+ private void resolveFiles(File dir, FileFilter filter, boolean recursive, String path, Map<String,File> files,
+ boolean flatten) {
if (doNotCopy(dir.getName())) {
return;
@@ -951,8 +932,7 @@
resolveFiles(file, filter, recursive, nextPath, files, flatten);
}
// Directories are ignored otherwise
- }
- else {
+ } else {
String p = appendPath(path, file.getName());
if (files.containsKey(p))
warning("Include-Resource overwrites entry %s from file %s", p, file);
@@ -961,8 +941,8 @@
}
}
- private void noSuchFile(Jar jar, String clause, Map<String, String> extra, String source,
- String destinationPath) throws Exception {
+ private void noSuchFile(Jar jar, String clause, Map<String,String> extra, String source, String destinationPath)
+ throws Exception {
Jar src = getJarFromName(source, "Include-Resource " + source);
if (src != null) {
// Do not touch the manifest so this also
@@ -970,16 +950,14 @@
src.setDoNotTouchManifest();
JarResource jarResource = new JarResource(src);
jar.putResource(destinationPath, jarResource);
- }
- else {
+ } else {
Resource lastChance = make.process(source);
if (lastChance != null) {
String x = extra.get("extra");
if (x != null)
lastChance.setExtra(x);
jar.putResource(destinationPath, lastChance);
- }
- else
+ } else
error("Input file does not exist: " + source);
}
}
@@ -994,8 +972,8 @@
* @throws ZipException
* @throws IOException
*/
- private void extractFromJar(Jar jar, String source, String destination, boolean absentIsOk)
- throws ZipException, IOException {
+ private void extractFromJar(Jar jar, String source, String destination, boolean absentIsOk) throws ZipException,
+ IOException {
// Inline all resources and classes from another jar
// optionally appended with a modified regular expression
// like @zip.jar!/META-INF/MANIFEST.MF
@@ -1018,8 +996,7 @@
return;
error("Can not find JAR file " + source);
- }
- else {
+ } else {
addAll(jar, sub, instr, destination);
}
}
@@ -1027,8 +1004,10 @@
/**
* Add all the resources in the given jar that match the given filter.
*
- * @param sub the jar
- * @param filter a pattern that should match the resoures in sub to be added
+ * @param sub
+ * the jar
+ * @param filter
+ * a pattern that should match the resoures in sub to be added
*/
public boolean addAll(Jar to, Jar sub, Instruction filter) {
return addAll(to, sub, filter, "");
@@ -1037,8 +1016,10 @@
/**
* Add all the resources in the given jar that match the given filter.
*
- * @param sub the jar
- * @param filter a pattern that should match the resoures in sub to be added
+ * @param sub
+ * the jar
+ * @param filter
+ * a pattern that should match the resoures in sub to be added
*/
public boolean addAll(Jar to, Jar sub, Instruction filter, String destination) {
boolean dupl = false;
@@ -1047,14 +1028,12 @@
continue;
if (filter == null || filter.matches(name) != filter.isNegated())
- dupl |= to.putResource(Processor.appendPath(destination, name),
- sub.getResource(name), true);
+ dupl |= to.putResource(Processor.appendPath(destination, name), sub.getResource(name), true);
}
return dupl;
}
- private void copy(Jar jar, String path, File from, boolean preprocess, Map<String, String> extra)
- throws Exception {
+ private void copy(Jar jar, String path, File from, boolean preprocess, Map<String,String> extra) throws Exception {
if (doNotCopy(from.getName()))
return;
@@ -1064,8 +1043,7 @@
for (int i = 0; i < files.length; i++) {
copy(jar, appendPath(path, files[i].getName()), files[i], preprocess, extra);
}
- }
- else {
+ } else {
if (from.exists()) {
Resource resource = new FileResource(from);
if (preprocess) {
@@ -1081,8 +1059,7 @@
if (isTrue(extra.get(LIB_DIRECTIVE))) {
setProperty(BUNDLE_CLASSPATH, append(getProperty(BUNDLE_CLASSPATH), path));
}
- }
- else {
+ } else {
error("Input file does not exist: " + from);
}
}
@@ -1242,16 +1219,15 @@
public String _maven_version(String args[]) {
if (args.length > 2)
error("${maven_version} macro receives too many arguments " + Arrays.toString(args));
- else
- if (args.length < 2)
- error("${maven_version} macro has no arguments, use ${maven_version;1.2.3-SNAPSHOT}");
- else {
- return cleanupVersion(args[1]);
- }
+ else if (args.length < 2)
+ error("${maven_version} macro has no arguments, use ${maven_version;1.2.3-SNAPSHOT}");
+ else {
+ return cleanupVersion(args[1]);
+ }
return null;
}
- public String _permissions(String args[]) throws IOException {
+ public String _permissions(String args[]) {
StringBuilder sb = new StringBuilder();
for (String arg : args) {
@@ -1268,16 +1244,12 @@
sb.append(exp);
sb.append("\" \"export\")\r\n");
}
- }
+ } else if ("admin".equals(arg) || "all".equals(arg)) {
+ sb.append("(org.osgi.framework.AdminPermission)");
+ } else if ("permissions".equals(arg))
+ ;
else
- if ("admin".equals(arg) || "all".equals(arg)) {
- sb.append("(org.osgi.framework.AdminPermission)");
- }
- else
- if ("permissions".equals(arg))
- ;
- else
- error("Invalid option in ${permissions}: %s", arg);
+ error("Invalid option in ${permissions}: %s", arg);
}
return sb.toString();
}
@@ -1293,7 +1265,7 @@
/**
* Check if the given resource is in scope of this bundle. That is, it
* checks if the Include-Resource includes this resource or if it is a class
- * file it is on the class path and the Export-Pacakge or Private-Package
+ * file it is on the class path and the Export-Package or Private-Package
* include this resource.
*
* @param f
@@ -1303,8 +1275,7 @@
Parameters clauses = parseHeader(getProperty(Constants.EXPORT_PACKAGE));
clauses.putAll(parseHeader(getProperty(Constants.PRIVATE_PACKAGE)));
if (isTrue(getProperty(Constants.UNDERTEST))) {
- clauses.putAll(parseHeader(getProperty(Constants.TESTPACKAGES,
- "test;presence:=optional")));
+ clauses.putAll(parseHeader(getProperty(Constants.TESTPACKAGES, "test;presence:=optional")));
}
Collection<String> ir = getIncludedResourcePrefixes();
@@ -1313,7 +1284,12 @@
for (File r : resources) {
String cpEntry = getClasspathEntrySuffix(r);
+
if (cpEntry != null) {
+
+ if (cpEntry.equals("")) // Meaning we actually have a CPE
+ return true;
+
String pack = Descriptors.getPackage(cpEntry);
Instruction i = matches(instructions, pack, null, r.getName());
if (i != null)
@@ -1340,7 +1316,7 @@
private Collection<String> getIncludedResourcePrefixes() {
List<String> prefixes = new ArrayList<String>();
Parameters includeResource = getIncludeResource();
- for (Entry<String, Attrs> p : includeResource.entrySet()) {
+ for (Entry<String,Attrs> p : includeResource.entrySet()) {
if (p.getValue().containsKey("literal"))
continue;
@@ -1354,19 +1330,26 @@
}
/**
- * Answer the string of the resource that it has in the container.
+ * Answer the string of the resource that it has in the container. It is
+ * possible that the resource is a classpath entry. In that case an empty
+ * string is returned.
*
- * @param resource The resource to look for
- * @return
+ * @param resource
+ * The resource to look for
+ * @return A suffix on the classpath or "" if the resource is a class path
+ * entry
* @throws Exception
*/
public String getClasspathEntrySuffix(File resource) throws Exception {
for (Jar jar : getClasspath()) {
File source = jar.getSource();
if (source != null) {
+
source = source.getCanonicalFile();
String sourcePath = source.getAbsolutePath();
String resourcePath = resource.getAbsolutePath();
+ if (sourcePath.equals(resourcePath))
+ return ""; // Matches a classpath entry
if (resourcePath.startsWith(sourcePath)) {
// Make sure that the path name is translated correctly
@@ -1381,11 +1364,9 @@
}
/**
- * doNotCopy
- *
- * The doNotCopy variable maintains a patter for files that should not be
- * copied. There is a default {@link #DEFAULT_DO_NOT_COPY} but this ca be
- * overridden with the {@link Constants#DONOTCOPY} property.
+ * doNotCopy The doNotCopy variable maintains a patter for files that should
+ * not be copied. There is a default {@link #DEFAULT_DO_NOT_COPY} but this
+ * ca be overridden with the {@link Constants#DONOTCOPY} property.
*/
public boolean doNotCopy(String v) {
@@ -1442,7 +1423,7 @@
if (tree == null)
tree = differ.tree(this);
- for (Entry<String, Attrs> entry : diffs.entrySet()) {
+ for (Entry<String,Attrs> entry : diffs.entrySet()) {
String path = entry.getKey();
File file = getFile(path);
if (!file.isFile()) {
@@ -1470,11 +1451,9 @@
error("Differ %s", p);
else {
if (warning)
- warning("Diff found a difference in %s for packages %s", file,
- instructions);
+ warning("Diff found a difference in %s for packages %s", file, instructions);
else
- error("Diff found a difference in %s for packages %s", file,
- instructions);
+ error("Diff found a difference in %s for packages %s", file, instructions);
show(p, "", warning);
}
}
@@ -1529,7 +1508,7 @@
Baseline baseline = new Baseline(this, differ);
- for (Entry<String, Attrs> entry : diffs.entrySet()) {
+ for (Entry<String,Attrs> entry : diffs.entrySet()) {
String path = entry.getKey();
File file = getFile(path);
if (!file.isFile()) {
@@ -1540,9 +1519,8 @@
Set<Info> infos = baseline.baseline(dot, other, null);
for (Info info : infos) {
if (info.mismatch) {
- error("%s %-50s %-10s %-10s %-10s %-10s %-10s\n", info.mismatch ? '*' : ' ',
- info.packageName, info.packageDiff.getDelta(), info.newerVersion,
- info.olderVersion, info.suggestedVersion,
+ error("%s %-50s %-10s %-10s %-10s %-10s %-10s\n", info.mismatch ? '*' : ' ', info.packageName,
+ info.packageDiff.getDelta(), info.newerVersion, info.olderVersion, info.suggestedVersion,
info.suggestedIfProviders == null ? "-" : info.suggestedIfProviders);
}
}
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/BundleId.java b/bundleplugin/src/main/java/aQute/lib/osgi/BundleId.java
index e500e53..87fc25f 100644
--- a/bundleplugin/src/main/java/aQute/lib/osgi/BundleId.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/BundleId.java
@@ -1,9 +1,7 @@
package aQute.lib.osgi;
-
/**
* Holds the bundle bsn + version pair
- *
*/
public class BundleId implements Comparable<BundleId> {
final String bsn;
@@ -29,16 +27,16 @@
public boolean equals(Object o) {
return this == o || ((o instanceof BundleId) && compareTo((BundleId) o) == 0);
}
-
+
public int hashCode() {
return bsn.hashCode() ^ version.hashCode();
}
public int compareTo(BundleId other) {
int result = bsn.compareTo(other.bsn);
- if ( result != 0)
+ if (result != 0)
return result;
-
+
return version.compareTo(other.version);
}
}
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/ClassDataCollector.java b/bundleplugin/src/main/java/aQute/lib/osgi/ClassDataCollector.java
index c878665..7c3d759 100644
--- a/bundleplugin/src/main/java/aQute/lib/osgi/ClassDataCollector.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/ClassDataCollector.java
@@ -3,89 +3,81 @@
import aQute.lib.osgi.Descriptors.TypeRef;
public class ClassDataCollector {
- public void classBegin(int access, TypeRef name) {
- }
+ public void classBegin(int access, TypeRef name) {}
- public boolean classStart(int access, TypeRef className) {
- classBegin(access,className);
- return true;
- }
+ public boolean classStart(int access, TypeRef className) {
+ classBegin(access, className);
+ return true;
+ }
- public void extendsClass(TypeRef zuper) throws Exception {
- }
+ public void extendsClass(TypeRef zuper) throws Exception {}
- public void implementsInterfaces(TypeRef[] interfaces) throws Exception {
- }
+ public void implementsInterfaces(TypeRef[] interfaces) throws Exception {}
- public void addReference(TypeRef ref) {
- }
+ public void addReference(TypeRef ref) {}
- public void annotation(Annotation annotation) {
- }
+ public void annotation(Annotation annotation) {}
- public void parameter(int p) {
- }
+ public void parameter(int p) {}
- public void method(Clazz.MethodDef defined) {
- }
+ public void method(Clazz.MethodDef defined) {}
- public void field(Clazz.FieldDef defined) {
- }
+ public void field(Clazz.FieldDef defined) {}
- public void reference(Clazz.MethodDef referenced) {
- }
+ public void reference(Clazz.MethodDef referenced) {}
- public void reference(Clazz.FieldDef referenced) {
- }
+ public void reference(Clazz.FieldDef referenced) {}
- public void classEnd() throws Exception {
- }
+ public void classEnd() throws Exception {}
- public void deprecated() throws Exception {
- }
+ public void deprecated() throws Exception {}
-
- /**
- * The EnclosingMethod attribute
- *
- * @param cName The name of the enclosing class, never null. Name is with slashes.
- * @param mName The name of the enclosing method in the class with cName or null
- * @param mDescriptor The descriptor of this type
- */
+ /**
+ * The EnclosingMethod attribute
+ *
+ * @param cName
+ * The name of the enclosing class, never null. Name is with
+ * slashes.
+ * @param mName
+ * The name of the enclosing method in the class with cName or
+ * null
+ * @param mDescriptor
+ * The descriptor of this type
+ */
public void enclosingMethod(TypeRef cName, String mName, String mDescriptor) {
-
+
}
/**
* The InnerClass attribute
*
- * @param innerClass The name of the inner class (with slashes). Can be null.
- * @param outerClass The name of the outer class (with slashes) Can be null.
- * @param innerName The name inside the outer class, can be null.
- * @param modifiers The access flags
- * @throws Exception
+ * @param innerClass
+ * The name of the inner class (with slashes). Can be null.
+ * @param outerClass
+ * The name of the outer class (with slashes) Can be null.
+ * @param innerName
+ * The name inside the outer class, can be null.
+ * @param modifiers
+ * The access flags
+ * @throws Exception
*/
- public void innerClass(TypeRef innerClass, TypeRef outerClass, String innerName,
- int innerClassAccessFlags) throws Exception {
- }
+ public void innerClass(TypeRef innerClass, TypeRef outerClass, String innerName, int innerClassAccessFlags)
+ throws Exception {}
- public void signature(String signature) {
- }
+ public void signature(String signature) {}
- public void constant(Object object) {
- }
+ public void constant(Object object) {}
- public void memberEnd() {
- }
+ public void memberEnd() {}
public void version(int minor, int major) {
// TODO Auto-generated method stub
-
+
}
public void referenceMethod(int access, TypeRef className, String method, String descriptor) {
// TODO Auto-generated method stub
-
+
}
}
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/Clazz.java b/bundleplugin/src/main/java/aQute/lib/osgi/Clazz.java
index e182e1f..d54b084 100755
--- a/bundleplugin/src/main/java/aQute/lib/osgi/Clazz.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/Clazz.java
@@ -87,10 +87,8 @@
}
- 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 @@
*
* @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 @@
}
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 @@
InputStream in = resource.openInputStream();
try {
return parseClassFile(in, cd);
- } finally {
+ }
+ finally {
in.close();
}
}
@@ -381,7 +380,8 @@
try {
this.cd = cd;
return parseClassFile(din);
- } finally {
+ }
+ finally {
cd = null;
din.close();
}
@@ -409,59 +409,59 @@
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 0 :
+ break process;
+ case 1 :
+ constantUtf8(in, poolIndex);
+ break;
- case 3:
- constantInteger(in, poolIndex);
- break;
+ case 3 :
+ constantInteger(in, poolIndex);
+ break;
- case 4:
- constantFloat(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;
+ // 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 6 :
+ constantDouble(in, poolIndex);
+ poolIndex++;
+ break;
- case 7:
- constantClass(in, poolIndex);
- break;
+ case 7 :
+ constantClass(in, poolIndex);
+ break;
- case 8:
- constantString(in, poolIndex);
- break;
+ case 8 :
+ constantString(in, poolIndex);
+ break;
- case 10: // Method ref
- case 11: // Interface Method ref
- methodRef(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;
+ // 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;
+ // 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 @@
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 @@
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 @@
// 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 @@
Set<TypeRef> xref = this.xref;
reset();
return xref;
- } finally {
+ }
+ finally {
if (cd != null)
cd.classEnd();
}
@@ -633,8 +629,7 @@
pool[poolIndex] = intPool[poolIndex];
}
- protected void pool(Object[] pool, int[] intPool) {
- }
+ protected void pool(Object[] pool, int[] intPool) {}
/**
* @param in
@@ -762,8 +757,7 @@
* 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 @@
* 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 @@
* }
* </pre>
*
- *
* @param in
* @throws IOException
*/
@@ -996,83 +988,84 @@
while (bb.remaining() > 0) {
int instruction = 0xFF & bb.get();
switch (instruction) {
- case OpCodes.ldc:
- lastReference = 0xFF & bb.get();
- break;
+ case OpCodes.ldc :
+ lastReference = 0xFF & bb.get();
+ break;
- case OpCodes.ldc_w:
- lastReference = 0xFFFF & bb.getShort();
- 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.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.invokevirtual : {
+ 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.invokeinterface : {
+ 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.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);
+ 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;
+ }
+ 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;
- }
+ 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 @@
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 @@
}
}
- 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 @@
}
}
- 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 @@
}
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 @@
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 '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 '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 '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 '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 '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 '@' : // 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;
+ 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);
+ default :
+ throw new IllegalArgumentException("Invalid value for Annotation ElementValue tag " + tag);
}
}
@@ -1213,9 +1203,7 @@
/**
* 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 @@
}
/**
- * .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 boolean is(QUERY query, Instruction instr, Analyzer analyzer) throws Exception {
switch (query) {
- case ANY:
- return true;
+ case ANY :
+ return true;
- case NAMED:
- if (instr.matches(getClassName().getDottedOnly()))
- return !instr.isNegated();
- return false;
-
- 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;
-
- case EXTENDS:
- if (zuper == null)
return false;
- if (instr.matches(zuper.getDottedOnly()))
- return !instr.isNegated();
- break;
-
- case PUBLIC:
- return Modifier.isPublic(accessx);
-
- case CONCRETE:
- return !Modifier.isAbstract(accessx);
-
- case ANNOTATED:
- if (annotations == null)
+ case VERSION :
+ String v = major + "." + minor;
+ if (instr.matches(v))
+ return !instr.isNegated();
return false;
- for (TypeRef annotation : annotations) {
- if (instr.matches(annotation.getFQN()))
+ case IMPLEMENTS :
+ for (int i = 0; interfaces != null && i < interfaces.length; i++) {
+ if (instr.matches(interfaces[i].getDottedOnly()))
+ return !instr.isNegated();
+ }
+ break;
+
+ case EXTENDS :
+ if (zuper == null)
+ return false;
+
+ if (instr.matches(zuper.getDottedOnly()))
return !instr.isNegated();
- }
+ break;
- return false;
+ case PUBLIC :
+ return Modifier.isPublic(accessx);
- case RUNTIMEANNOTATIONS:
- return hasClassAnnotations;
- case CLASSANNOTATIONS:
- return hasClassAnnotations;
+ case CONCRETE :
+ return !Modifier.isAbstract(accessx);
- case ABSTRACT:
- return Modifier.isAbstract(accessx);
+ case ANNOTATED :
+ if (annotations == null)
+ return false;
- case IMPORTS:
- for (PackageRef imp : imports) {
- if (instr.matches(imp.getFQN()))
- return !instr.isNegated();
- }
+ for (TypeRef annotation : annotations) {
+ if (instr.matches(annotation.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 @@
/**
* 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 @@
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 @@
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);
}
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/CombinedResource.java b/bundleplugin/src/main/java/aQute/lib/osgi/CombinedResource.java
index e8566db..d76b695 100644
--- a/bundleplugin/src/main/java/aQute/lib/osgi/CombinedResource.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/CombinedResource.java
@@ -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 @@
// Ignore
}
};
- for ( Resource r : resources ) {
+ for (Resource r : resources) {
r.write(unclosable);
unclosable.flush();
}
@@ -47,5 +46,4 @@
resources.add(r);
}
-
}
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/CommandResource.java b/bundleplugin/src/main/java/aQute/lib/osgi/CommandResource.java
index c9e3c8a..0fa43fe 100644
--- a/bundleplugin/src/main/java/aQute/lib/osgi/CommandResource.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/CommandResource.java
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-
package aQute.lib.osgi;
import java.io.*;
@@ -22,10 +21,10 @@
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 @@
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());
}
}
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/Constants.java b/bundleplugin/src/main/java/aQute/lib/osgi/Constants.java
index 8df703f..df0bbf0 100644
--- a/bundleplugin/src/main/java/aQute/lib/osgi/Constants.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/Constants.java
@@ -12,294 +12,293 @@
* @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 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 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 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 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 };
+ 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:";
+ 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 KEYSTORE_LOCATION_DIRECTIVE = "keystore:";
+ String KEYSTORE_PROVIDER_DIRECTIVE = "provider:";
+ String KEYSTORE_PASSWORD_DIRECTIVE = "password:";
+ String SIGN_PASSWORD_DIRECTIVE = "sign-password:";
- String NONE = "none";
+ 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
+ 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
- };
+ // TODO
+ };
- String USES_USES = "<<USES>>";
- String CURRENT_USES = "@uses";
- String IMPORT_REFERENCE = "reference";
- String IMPORT_PRIVATE = "private";
- String[] importDirectives = {
- IMPORT_REFERENCE, IMPORT_PRIVATE };
+ 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)");
+ 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 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 CURRENT_VERSION = "@";
+ String CURRENT_PACKAGE = "@package";
- String BUILDFILES = "buildfiles";
+ String BUILDFILES = "buildfiles";
- String EMPTY_HEADER = "<<EMPTY>>";
+ String EMPTY_HEADER = "<<EMPTY>>";
- String EMBEDDED_REPO = "/embedded-repo.jar";
- String LAUNCHER_PLUGIN = "Launcher-Plugin";
- String TESTER_PLUGIN = "Tester-Plugin";
+ 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_LAUNCHER_BSN = "biz.aQute.launcher";
+ String DEFAULT_TESTER_BSN = "biz.aQute.junit";
- String DEFAULT_DO_NOT_COPY = "CVS|\\.svn|\\.git|\\.DS_Store";
+ 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:";
+ 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:";
+ 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();
+ 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 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 = 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 Set<String> SET_COMPONENT_DIRECTIVES_1_1 = //
+ new HashSet<String>(Arrays.asList(
+ COMPONENT_VERSION,
+ COMPONENT_CONFIGURATION_POLICY,
+ COMPONENT_MODIFIED,
+ COMPONENT_ACTIVATE,
+ COMPONENT_DEACTIVATE));
}
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/Descriptors.java b/bundleplugin/src/main/java/aQute/lib/osgi/Descriptors.java
index 366ca57..c15e436 100644
--- a/bundleplugin/src/main/java/aQute/lib/osgi/Descriptors.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/Descriptors.java
@@ -5,30 +5,29 @@
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 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 @@
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 String toString() {
return fqn;
}
-
+
boolean isDefaultPackage() {
return this.fqn.equals(".");
}
@@ -109,16 +110,16 @@
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 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 @@
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 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 String getSourcePath() {
return component.getSourcePath();
}
-
+
public boolean isPrimitive() {
return false;
}
@@ -294,17 +295,17 @@
}
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 @@
} 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 @@
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 @@
}
switch (c) {
- case 'L':
- while ((c = descriptor.charAt(index++)) != ';') {
- // TODO
+ 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;
+ 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 @@
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 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 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 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));
}
}
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/Domain.java b/bundleplugin/src/main/java/aQute/lib/osgi/Domain.java
index b6ef379..f520378 100644
--- a/bundleplugin/src/main/java/aQute/lib/osgi/Domain.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/Domain.java
@@ -13,7 +13,6 @@
* 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 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 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 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 Parameters getIncludeResource() {
Parameters ic = getParameters(INCLUDE_RESOURCE);
- ic.putAll( getParameters(INCLUDERESOURCE));
+ ic.putAll(getParameters(INCLUDERESOURCE));
return ic;
}
@@ -232,24 +241,24 @@
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));
}
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/EmbeddedResource.java b/bundleplugin/src/main/java/aQute/lib/osgi/EmbeddedResource.java
index ebc93ee..3aff084 100755
--- a/bundleplugin/src/main/java/aQute/lib/osgi/EmbeddedResource.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/EmbeddedResource.java
@@ -75,7 +75,8 @@
InputStream in = resource.openInputStream();
try {
build(sub, in, resource.lastModified());
- } catch( Exception e ) {
+ }
+ catch (Exception e) {
e.printStackTrace();
}
finally {
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/FileResource.java b/bundleplugin/src/main/java/aQute/lib/osgi/FileResource.java
index b849878..4d2459d 100755
--- a/bundleplugin/src/main/java/aQute/lib/osgi/FileResource.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/FileResource.java
@@ -6,7 +6,7 @@
public class FileResource implements Resource {
File file;
String extra;
-
+
public FileResource(File file) {
this.file = file;
}
@@ -16,11 +16,7 @@
}
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 @@
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 @@
}
}
- 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 void setExtra(String extra) {
this.extra = extra;
}
-
+
public long size() {
- return (int) file.length();
+ return (int) file.length();
}
}
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/Instruction.java b/bundleplugin/src/main/java/aQute/lib/osgi/Instruction.java
index 9263e3c..c92de90 100755
--- a/bundleplugin/src/main/java/aQute/lib/osgi/Instruction.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/Instruction.java
@@ -60,8 +60,7 @@
if (s.startsWith("!")) {
negated = true;
s = s.substring(1);
- }
- else
+ } else
negated = false;
if (input.equals("*")) {
@@ -75,8 +74,7 @@
if (s.startsWith("=")) {
match = s.substring(1);
literal = true;
- }
- else {
+ } else {
boolean wildcards = false;
StringBuilder sb = new StringBuilder();
@@ -90,8 +88,7 @@
sb.append("(\\..*)?");
wildcards = true;
break loop;
- }
- else
+ } else
sb.append("\\.");
break;
@@ -119,8 +116,7 @@
if (!wildcards) {
literal = true;
match = s;
- }
- else {
+ } else {
literal = false;
match = sb.toString();
}
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/Instructions.java b/bundleplugin/src/main/java/aQute/lib/osgi/Instructions.java
index e74150c..679c374 100644
--- a/bundleplugin/src/main/java/aQute/lib/osgi/Instructions.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/Instructions.java
@@ -4,25 +4,24 @@
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 @@
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 @@
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 @@
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 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 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 @@
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 @@
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;
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/Jar.java b/bundleplugin/src/main/java/aQute/lib/osgi/Jar.java
index 497198b..032a7d1 100755
--- a/bundleplugin/src/main/java/aQute/lib/osgi/Jar.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/Jar.java
@@ -18,21 +18,21 @@
DEFLATE, STORE
}
- public static final Object[] EMPTY_ARRAY = new Jar[0];
- final Map<String, Resource> resources = new TreeMap<String, Resource>();
- final Map<String, Map<String, Resource>> directories = new TreeMap<String, Map<String, Resource>>();
- Manifest manifest;
- boolean manifestFirst;
- String name;
- File source;
- ZipFile zipFile;
- long lastModified;
- String lastModifiedReason;
- Reporter reporter;
- boolean doNotTouchManifest;
- boolean nomanifest;
- Compression compression = Compression.DEFLATE;
- boolean closed;
+ public static final Object[] EMPTY_ARRAY = new Jar[0];
+ final Map<String,Resource> resources = new TreeMap<String,Resource>();
+ final Map<String,Map<String,Resource>> directories = new TreeMap<String,Map<String,Resource>>();
+ Manifest manifest;
+ boolean manifestFirst;
+ String name;
+ File source;
+ ZipFile zipFile;
+ long lastModified;
+ String lastModifiedReason;
+ Reporter reporter;
+ boolean doNotTouchManifest;
+ boolean nomanifest;
+ Compression compression = Compression.DEFLATE;
+ boolean closed;
public Jar(String name) {
this.name = name;
@@ -46,8 +46,7 @@
else if (dirOrFile.isFile()) {
zipFile = ZipResource.build(this, dirOrFile);
} else {
- throw new IllegalArgumentException("A Jar can only accept a valid file or directory: "
- + dirOrFile);
+ throw new IllegalArgumentException("A Jar can only accept a valid file or directory: " + dirOrFile);
}
}
@@ -119,9 +118,9 @@
manifestFirst = true;
}
String dir = getDirectory(path);
- Map<String, Resource> s = directories.get(dir);
+ Map<String,Resource> s = directories.get(dir);
if (s == null) {
- s = new TreeMap<String, Resource>();
+ s = new TreeMap<String,Resource>();
directories.put(dir, s);
int n = dir.lastIndexOf('/');
while (n > 0) {
@@ -156,23 +155,23 @@
return path.substring(0, n);
}
- public Map<String, Map<String, Resource>> getDirectories() {
+ public Map<String,Map<String,Resource>> getDirectories() {
check();
return directories;
}
- public Map<String, Resource> getResources() {
+ public Map<String,Resource> getResources() {
check();
return resources;
}
- public boolean addDirectory(Map<String, Resource> directory, boolean overwrite) {
+ public boolean addDirectory(Map<String,Resource> directory, boolean overwrite) {
check();
boolean duplicates = false;
if (directory == null)
return false;
- for (Map.Entry<String, Resource> entry : directory.entrySet()) {
+ for (Map.Entry<String,Resource> entry : directory.entrySet()) {
String key = entry.getKey();
if (!key.endsWith(".java")) {
duplicates |= putResource(key, entry.getValue(), overwrite);
@@ -211,7 +210,8 @@
try {
Manifest m = new Manifest(fin);
setManifest(m);
- } finally {
+ }
+ finally {
fin.close();
}
}
@@ -222,12 +222,14 @@
OutputStream out = new FileOutputStream(file);
try {
write(out);
- } finally {
+ }
+ finally {
IO.close(out);
}
return;
- } catch (Exception t) {
+ }
+ catch (Exception t) {
file.delete();
throw t;
}
@@ -240,16 +242,15 @@
public void write(OutputStream out) throws Exception {
check();
- ZipOutputStream jout = nomanifest || doNotTouchManifest ? new ZipOutputStream(out)
- : new JarOutputStream(out);
+ ZipOutputStream jout = nomanifest || doNotTouchManifest ? new ZipOutputStream(out) : new JarOutputStream(out);
switch (compression) {
- case STORE:
- jout.setMethod(ZipOutputStream.DEFLATED);
- break;
+ case STORE :
+ jout.setMethod(ZipOutputStream.DEFLATED);
+ break;
- default:
- // default is DEFLATED
+ default :
+ // default is DEFLATED
}
Set<String> done = new HashSet<String>();
@@ -264,7 +265,7 @@
} else
doManifest(done, jout);
- for (Map.Entry<String, Resource> entry : getResources().entrySet()) {
+ for (Map.Entry<String,Resource> entry : getResources().entrySet()) {
// Skip metainf contents
if (!done.contains(entry.getKey()))
writeResource(jout, directories, entry.getKey(), entry.getValue());
@@ -309,11 +310,8 @@
/**
* Unfortunately we have to write our own manifest :-( because of a stupid
* bug in the manifest code. It tries to handle UTF-8 but the way it does it
- * it makes the bytes platform dependent.
- *
- * So the following code outputs the manifest.
- *
- * A Manifest consists of
+ * it makes the bytes platform dependent. So the following code outputs the
+ * manifest. A Manifest consists of
*
* <pre>
* 'Manifest-Version: 1.0\r\n'
@@ -328,11 +326,12 @@
*
* Lines in the manifest should not exceed 72 bytes (! this is where the
* manifest screwed up as well when 16 bit unicodes were used).
- *
* <p>
* As a bonus, we can now sort the manifest!
*/
- static byte[] CONTINUE = new byte[] { '\r', '\n', ' ' };
+ static byte[] CONTINUE = new byte[] {
+ '\r', '\n', ' '
+ };
/**
* Main function to output a manifest properly in UTF-8.
@@ -362,7 +361,6 @@
/**
* Write out an entry, handling proper unicode and line length constraints
- *
*/
private static void writeEntry(OutputStream out, String name, String value) throws IOException {
int n = write(out, 0, name + ": ");
@@ -428,15 +426,15 @@
* when something fails
*/
private static void attributes(Attributes value, OutputStream out) throws IOException {
- TreeMap<String, String> map = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
- for (Map.Entry<Object, Object> entry : value.entrySet()) {
+ TreeMap<String,String> map = new TreeMap<String,String>(String.CASE_INSENSITIVE_ORDER);
+ for (Map.Entry<Object,Object> entry : value.entrySet()) {
map.put(entry.getKey().toString(), entry.getValue().toString());
}
map.remove("Manifest-Version"); // get rid of
// manifest
// version
- for (Map.Entry<String, String> entry : map.entrySet()) {
+ for (Map.Entry<String,String> entry : map.entrySet()) {
writeEntry(out, entry.getKey(), entry.getValue());
}
}
@@ -444,7 +442,7 @@
private static Manifest clean(Manifest org) {
Manifest result = new Manifest();
- for (Map.Entry<?, ?> entry : org.getMainAttributes().entrySet()) {
+ for (Map.Entry< ? , ? > entry : org.getMainAttributes().entrySet()) {
String nice = clean((String) entry.getValue());
result.getMainAttributes().put(entry.getKey(), nice);
}
@@ -455,7 +453,7 @@
result.getEntries().put(name, attrs);
}
- for (Map.Entry<?, ?> entry : org.getAttributes(name).entrySet()) {
+ for (Map.Entry< ? , ? > entry : org.getAttributes(name).entrySet()) {
String nice = clean((String) entry.getValue());
attrs.put((Attributes.Name) entry.getKey(), nice);
}
@@ -475,8 +473,8 @@
return sb.toString();
}
- private void writeResource(ZipOutputStream jout, Set<String> directories, String path,
- Resource resource) throws Exception {
+ private void writeResource(ZipOutputStream jout, Set<String> directories, String path, Resource resource)
+ throws Exception {
if (resource == null)
return;
try {
@@ -493,13 +491,13 @@
jout.putNextEntry(ze);
resource.write(jout);
jout.closeEntry();
- } catch (Exception e) {
+ }
+ catch (Exception e) {
throw new Exception("Problem writing resource " + path, e);
}
}
- void createDirectories(Set<String> directories, ZipOutputStream zip, String name)
- throws IOException {
+ void createDirectories(Set<String> directories, ZipOutputStream zip, String name) throws IOException {
int index = name.lastIndexOf('/');
if (index > 0) {
String path = name.substring(0, index);
@@ -545,8 +543,7 @@
continue;
if (filter == null || filter.matches(name) != filter.isNegated())
- dupl |= putResource(Processor.appendPath(destination, name), sub.getResource(name),
- true);
+ dupl |= putResource(Processor.appendPath(destination, name), sub.getResource(name), true);
}
return dupl;
}
@@ -556,7 +553,8 @@
if (zipFile != null)
try {
zipFile.close();
- } catch (IOException e) {
+ }
+ catch (IOException e) {
// Ignore
}
resources.clear();
@@ -589,7 +587,7 @@
check();
List<String> list = new ArrayList<String>(directories.size());
- for (Map.Entry<String, Map<String, Resource>> i : directories.entrySet()) {
+ for (Map.Entry<String,Map<String,Resource>> i : directories.entrySet()) {
if (i.getValue() != null) {
String path = i.getKey();
String pack = path.replace('/', '.');
@@ -622,7 +620,7 @@
check();
Resource resource = resources.remove(path);
String dir = getDirectory(path);
- Map<String, Resource> mdir = directories.get(dir);
+ Map<String,Resource> mdir = directories.get(dir);
// must be != null
mdir.remove(path);
return resource;
@@ -644,7 +642,9 @@
public void calcChecksums(String algorithms[]) throws Exception {
check();
if (algorithms == null)
- algorithms = new String[] { "SHA", "MD5" };
+ algorithms = new String[] {
+ "SHA", "MD5"
+ };
Manifest m = getManifest();
if (m == null) {
@@ -659,7 +659,7 @@
byte buffer[] = new byte[30000];
- for (Map.Entry<String, Resource> entry : resources.entrySet()) {
+ for (Map.Entry<String,Resource> entry : resources.entrySet()) {
// Skip the manifest
if (entry.getKey().equals("META-INF/MANIFEST.MF"))
@@ -681,7 +681,8 @@
d.update(buffer, 0, size);
size = in.read(buffer);
}
- } finally {
+ }
+ finally {
in.close();
}
for (MessageDigest d : digests)
@@ -737,7 +738,7 @@
throw new IllegalArgumentException("Not a dir: " + dir.getAbsolutePath());
}
- for (Map.Entry<String, Resource> entry : getResources().entrySet()) {
+ for (Map.Entry<String,Resource> entry : getResources().entrySet()) {
File f = getFile(dir, entry.getKey());
f.getParentFile().mkdirs();
IO.copy(entry.getValue().openInputStream(), f);
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/JarResource.java b/bundleplugin/src/main/java/aQute/lib/osgi/JarResource.java
index 0c0adcd..c51aba3 100755
--- a/bundleplugin/src/main/java/aQute/lib/osgi/JarResource.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/JarResource.java
@@ -17,7 +17,8 @@
public void write(OutputStream out) throws Exception {
try {
jar.write(out);
- } catch (Exception e) {
+ }
+ catch (Exception e) {
e.printStackTrace();
throw e;
}
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/Macro.java b/bundleplugin/src/main/java/aQute/lib/osgi/Macro.java
index 4ddd625..36c16dd 100755
--- a/bundleplugin/src/main/java/aQute/lib/osgi/Macro.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/Macro.java
@@ -17,17 +17,10 @@
* based on a properties and a domain. The domain can implement functions that
* start with a "_" and take args[], the names of these functions are available
* as functions in the macro processor (without the _). Macros can nest to any
- * depth but may not contain loops.
- *
- * Add POSIX macros: ${#parameter} String length.
- *
- * ${parameter%word} Remove smallest suffix pattern.
- *
- * ${parameter%%word} Remove largest suffix pattern.
- *
- * ${parameter#word} Remove smallest prefix pattern.
- *
- * ${parameter##word} Remove largest prefix pattern.
+ * depth but may not contain loops. Add POSIX macros: ${#parameter} String
+ * length. ${parameter%word} Remove smallest suffix pattern. ${parameter%%word}
+ * Remove largest suffix pattern. ${parameter#word} Remove smallest prefix
+ * pattern. ${parameter##word} Remove largest prefix pattern.
*/
public class Macro implements Replacer {
Processor domain;
@@ -66,39 +59,32 @@
result.append(replace(variable.toString(), link));
return index;
}
+ } else if (c1 == begin)
+ nesting++;
+ else if (c1 == '\\' && index < line.length() - 1 && line.charAt(index) == '$') {
+ // remove the escape backslash and interpret the dollar
+ // as a
+ // literal
+ index++;
+ variable.append('$');
+ continue outer;
+ } else if (c1 == '$' && index < line.length() - 2) {
+ char c2 = line.charAt(index);
+ char terminator = getTerminator(c2);
+ if (terminator != 0) {
+ index = process(line, index + 1, c2, terminator, variable, link);
+ continue outer;
+ }
+ } else if (c1 == '.' && index < line.length() && line.charAt(index) == '/') {
+ // Found the sequence ./
+ if (index == 1 || Character.isWhitespace(line.charAt(index - 2))) {
+ // make sure it is preceded by whitespace or starts at begin
+ index++;
+ variable.append(domain.getBase().getAbsolutePath());
+ variable.append('/');
+ continue outer;
+ }
}
- else
- if (c1 == begin)
- nesting++;
- else
- if (c1 == '\\' && index < line.length() - 1 && line.charAt(index) == '$') {
- // remove the escape backslash and interpret the dollar
- // as a
- // literal
- index++;
- variable.append('$');
- continue outer;
- }
- else
- if (c1 == '$' && index < line.length() - 2) {
- char c2 = line.charAt(index);
- char terminator = getTerminator(c2);
- if (terminator != 0) {
- index = process(line, index + 1, c2, terminator, variable, link);
- continue outer;
- }
- }
- else
- if (c1 == '.' && index < line.length() && line.charAt(index) == '/') {
- // Found the sequence ./
- if (index == 1 || Character.isWhitespace(line.charAt(index - 2))) {
- // make sure it is preceded by whitespace or starts at begin
- index++;
- variable.append(domain.getBase().getAbsolutePath());
- variable.append('/');
- continue outer;
- }
- }
variable.append(c1);
}
result.append(variable);
@@ -171,12 +157,10 @@
}
if (!flattening && !key.equals("@"))
domain.warning("No translation found for macro: " + key);
- }
- else {
+ } else {
domain.warning("Found empty macro key");
}
- }
- else {
+ } else {
domain.warning("Found null macro key");
}
return "${" + key + "}";
@@ -235,18 +219,20 @@
else {
String cname = "_" + method.replaceAll("-", "_");
try {
- Method m = target.getClass().getMethod(cname, new Class[] {String[].class});
- return (String) m.invoke(target, new Object[] {args});
+ Method m = target.getClass().getMethod(cname, new Class[] {
+ String[].class
+ });
+ return (String) m.invoke(target, new Object[] {
+ args
+ });
}
catch (NoSuchMethodException e) {
// Ignore
}
catch (InvocationTargetException e) {
if (e.getCause() instanceof IllegalArgumentException) {
- domain.error("%s, for cmd: %s, arguments; %s", e.getMessage(), method,
- Arrays.toString(args));
- }
- else {
+ domain.error("%s, for cmd: %s, arguments; %s", e.getMessage(), method, Arrays.toString(args));
+ } else {
domain.warning("Exception in replace: " + e.getCause());
e.getCause().printStackTrace();
}
@@ -395,7 +381,6 @@
}
/**
- *
* replace ; <list> ; regex ; replace
*
* @param args
@@ -453,16 +438,12 @@
if (path.endsWith(".class")) {
String name = path.substring(0, path.length() - 6).replace('/', '.');
names.add(name);
+ } else if (path.endsWith(".java")) {
+ String name = path.substring(0, path.length() - 5).replace('/', '.');
+ names.add(name);
+ } else {
+ domain.warning("in toclassname, " + args[1] + " is not a class path because it does not end in .class");
}
- else
- if (path.endsWith(".java")) {
- String name = path.substring(0, path.length() - 5).replace('/', '.');
- names.add(name);
- }
- else {
- domain.warning("in toclassname, " + args[1]
- + " is not a class path because it does not end in .class");
- }
}
return Processor.join(names, ",");
}
@@ -495,8 +476,7 @@
if (args.length < 2) {
domain.warning("Need at least one file name for ${dir;...}");
return null;
- }
- else {
+ } else {
String del = "";
StringBuilder sb = new StringBuilder();
for (int i = 1; i < args.length; i++) {
@@ -516,8 +496,7 @@
if (args.length < 2) {
domain.warning("Need at least one file name for ${basename;...}");
return null;
- }
- else {
+ } else {
String del = "";
StringBuilder sb = new StringBuilder();
for (int i = 1; i < args.length; i++) {
@@ -537,8 +516,7 @@
if (args.length < 2) {
domain.warning("Need at least one file name for ${isfile;...}");
return null;
- }
- else {
+ } else {
boolean isfile = true;
for (int i = 1; i < args.length; i++) {
File f = new File(args[i]).getAbsoluteFile();
@@ -553,8 +531,7 @@
if (args.length < 2) {
domain.warning("Need at least one file name for ${isdir;...}");
return null;
- }
- else {
+ } else {
boolean isdir = true;
for (int i = 1; i < args.length; i++) {
File f = new File(args[i]).getAbsoluteFile();
@@ -568,28 +545,33 @@
public String _tstamp(String args[]) {
String format = "yyyyMMddHHmm";
long now = System.currentTimeMillis();
+ TimeZone tz = TimeZone.getTimeZone("UTC");
if (args.length > 1) {
format = args[1];
- if (args.length > 2) {
- now = Long.parseLong(args[2]);
- if (args.length > 3) {
- domain.warning("Too many arguments for tstamp: " + Arrays.toString(args));
- }
- }
}
+ if (args.length > 2) {
+ tz = TimeZone.getTimeZone(args[2]);
+ }
+ if (args.length > 3) {
+ now = Long.parseLong(args[3]);
+ }
+ if (args.length > 4) {
+ domain.warning("Too many arguments for tstamp: " + Arrays.toString(args));
+ }
+
SimpleDateFormat sdf = new SimpleDateFormat(format);
+ sdf.setTimeZone(tz);
+
return sdf.format(new Date(now));
}
/**
* Wildcard a directory. The lists can contain Instruction that are matched
- * against the given directory
- *
- * ${lsr;<dir>;<list>(;<list>)*} ${lsa;<dir>;<list>(;<list>)*}
+ * against the given directory ${lsr;<dir>;<list>(;<list>)*}
+ * ${lsa;<dir>;<list>(;<list>)*}
*
* @author aqute
- *
*/
public String _lsr(String args[]) {
@@ -602,22 +584,18 @@
String ls(String args[], boolean relative) {
if (args.length < 2)
- throw new IllegalArgumentException(
- "the ${ls} macro must at least have a directory as parameter");
+ throw new IllegalArgumentException("the ${ls} macro must at least have a directory as parameter");
File dir = domain.getFile(args[1]);
if (!dir.isAbsolute())
- throw new IllegalArgumentException(
- "the ${ls} macro directory parameter is not absolute: " + dir);
+ throw new IllegalArgumentException("the ${ls} macro directory parameter is not absolute: " + dir);
if (!dir.exists())
- throw new IllegalArgumentException(
- "the ${ls} macro directory parameter does not exist: " + dir);
+ throw new IllegalArgumentException("the ${ls} macro directory parameter does not exist: " + dir);
if (!dir.isDirectory())
throw new IllegalArgumentException(
- "the ${ls} macro directory parameter points to a file instead of a directory: "
- + dir);
+ "the ${ls} macro directory parameter points to a file instead of a directory: " + dir);
List<File> files = new ArrayList<File>(new SortedList<File>(dir.listFiles()));
@@ -652,9 +630,6 @@
* version="[${version;==;${@}},${version;=+;${@}})"
* </pre>
*
- *
- *
- *
* @param args
* @return
*/
@@ -662,9 +637,10 @@
final static Pattern MASK = Pattern.compile(MASK_STRING);
final static String _versionHelp = "${version;<mask>;<version>}, modify a version\n"
+ "<mask> ::= [ M [ M [ M [ MQ ]]]\n"
- + "M ::= '+' | '-' | MQ\n"
- + "MQ ::= '~' | '='";
- final static Pattern _versionPattern[] = new Pattern[] {null, null, MASK, Verifier.VERSION};
+ + "M ::= '+' | '-' | MQ\n" + "MQ ::= '~' | '='";
+ final static Pattern _versionPattern[] = new Pattern[] {
+ null, null, MASK, Verifier.VERSION
+ };
public String _version(String args[]) {
verifyCommand(args, _versionHelp, null, 2, 3);
@@ -699,26 +675,23 @@
if (c != '~') {
if (i == 3) {
result = version.getQualifier();
+ } else if (Character.isDigit(c)) {
+ // Handle masks like +00, =+0
+ result = String.valueOf(c);
+ } else {
+ int x = version.get(i);
+ switch (c) {
+ case '+' :
+ x++;
+ break;
+ case '-' :
+ x--;
+ break;
+ case '=' :
+ break;
+ }
+ result = Integer.toString(x);
}
- else
- if (Character.isDigit(c)) {
- // Handle masks like +00, =+0
- result = String.valueOf(c);
- }
- else {
- int x = version.get(i);
- switch (c) {
- case '+' :
- x++;
- break;
- case '-' :
- x--;
- break;
- case '=' :
- break;
- }
- result = Integer.toString(x);
- }
if (result != null) {
sb.append(del);
del = ".";
@@ -741,12 +714,14 @@
* @return
*/
- static Pattern RANGE_MASK = Pattern.compile("(\\[|\\()(" + MASK_STRING + "),("
- + MASK_STRING + ")(\\]|\\))");
+ static Pattern RANGE_MASK = Pattern.compile("(\\[|\\()(" + MASK_STRING + "),(" + MASK_STRING + ")(\\]|\\))");
static String _rangeHelp = "${range;<mask>[;<version>]}, range for version, if version not specified lookyp ${@}\n"
+ "<mask> ::= [ M [ M [ M [ MQ ]]]\n"
- + "M ::= '+' | '-' | MQ\n" + "MQ ::= '~' | '='";
- static Pattern _rangePattern[] = new Pattern[] {null, RANGE_MASK};
+ + "M ::= '+' | '-' | MQ\n"
+ + "MQ ::= '~' | '='";
+ static Pattern _rangePattern[] = new Pattern[] {
+ null, RANGE_MASK
+ };
public String _range(String args[]) {
verifyCommand(args, _rangeHelp, _rangePattern, 2, 3);
@@ -780,8 +755,7 @@
String s = sb.toString();
VersionRange vr = new VersionRange(s);
if (!(vr.includes(vr.getHigh()) || vr.includes(vr.getLow()))) {
- domain.error("${range} macro created an invalid range %s from %s and mask %s", s,
- version, spec);
+ domain.error("${range} macro created an invalid range %s from %s and mask %s", s, version, spec);
}
return sb.toString();
}
@@ -861,43 +835,36 @@
File f = domain.getFile(args[1]);
if (f.isFile()) {
return IO.collect(f);
+ } else if (f.isDirectory()) {
+ return Arrays.toString(f.list());
+ } else {
+ try {
+ URL url = new URL(args[1]);
+ return IO.collect(url, "UTF-8");
+ }
+ catch (MalformedURLException mfue) {
+ // Ignore here
+ }
+ return null;
}
- else
- if (f.isDirectory()) {
- return Arrays.toString(f.list());
- }
- else {
- try {
- URL url = new URL(args[1]);
- return IO.collect(url, "UTF-8");
- }
- catch (MalformedURLException mfue) {
- // Ignore here
- }
- return null;
- }
}
- public static void verifyCommand(String args[], String help, Pattern[] patterns, int low,
- int high) {
+ public static void verifyCommand(String args[], String help, Pattern[] patterns, int low, int high) {
String message = "";
if (args.length > high) {
message = "too many arguments";
- }
- else
- if (args.length < low) {
- message = "too few arguments";
- }
- else {
- for (int i = 0; patterns != null && i < patterns.length && i < args.length; i++) {
- if (patterns[i] != null) {
- Matcher m = patterns[i].matcher(args[i]);
- if (!m.matches())
- message += String.format("Argument %s (%s) does not match %s\n", i,
- args[i], patterns[i].pattern());
- }
+ } else if (args.length < low) {
+ message = "too few arguments";
+ } else {
+ for (int i = 0; patterns != null && i < patterns.length && i < args.length; i++) {
+ if (patterns[i] != null) {
+ Matcher m = patterns[i].matcher(args[i]);
+ if (!m.matches())
+ message += String.format("Argument %s (%s) does not match %s\n", i, args[i],
+ patterns[i].pattern());
}
}
+ }
if (message.length() != 0) {
StringBuilder sb = new StringBuilder();
String del = "${";
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/OpCodes.java b/bundleplugin/src/main/java/aQute/lib/osgi/OpCodes.java
index f0d3134..17b6d2b 100755
--- a/bundleplugin/src/main/java/aQute/lib/osgi/OpCodes.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/OpCodes.java
@@ -1,51 +1,58 @@
package aQute.lib.osgi;
public class OpCodes {
- final static short nop = 0x00; // [No change] performs
- // no
+ final static short nop = 0x00; // [No change]
+ // performs
+ // no
// operation
- final static short aconst_null = 0x01; // ? null pushes a null
+ final static short aconst_null = 0x01; // ? null pushes a
+ // null
// reference onto the stack
- final static short iconst_m1 = 0x02; // ? -1 loads the int
- // value -1
+ final static short iconst_m1 = 0x02; // ? -1 loads the
+ // int
+ // value -1
// onto the stack
final static short iconst_0 = 0x03; // ? 0 loads the int
- // value 0
+ // value 0
// onto the stack
final static short iconst_1 = 0x04; // ? 1 loads the int
- // value 1
+ // value 1
// onto the stack
final static short iconst_2 = 0x05; // ? 2 loads the int
- // value 2
+ // value 2
// onto the stack
final static short iconst_3 = 0x06; // ? 3 loads the int
- // value 3
+ // value 3
// onto the stack
final static short iconst_4 = 0x07; // ? 4 loads the int
- // value 4
+ // value 4
// onto the stack
final static short iconst_5 = 0x08; // ? 5 loads the int
- // value 5
+ // value 5
// onto the stack
- final static short lconst_0 = 0x09; // ? 0L pushes the long
- // 0 onto
+ final static short lconst_0 = 0x09; // ? 0L pushes the
+ // long
+ // 0 onto
// the stack
- final static short bipush = 0x10; // byte ? value pushes a
- // byte
+ final static short bipush = 0x10; // byte ? value
+ // pushes a
+ // byte
// onto the stack as an integer
// value
- final static short sipush = 0x11; // byte1, byte2 ? value
- // pushes a
+ final static short sipush = 0x11; // byte1, byte2 ?
+ // value
+ // pushes a
// signed integer (byte1 << 8 +
// byte2) onto the stack
- final static short ldc = 0x12; // index ? value pushes
- // a
+ final static short ldc = 0x12; // index ? value
+ // pushes
+ // a
// constant #index from a
// constant pool (String, int,
// float or class type) onto the
// stack
final static short ldc_w = 0x13; // indexbyte1,
- // indexbyte2 ?
+ // indexbyte2 ?
// value pushes a constant
// #index from a constant pool
// (String, int, float or class
@@ -53,393 +60,433 @@
// index is constructed as
// indexbyte1 << 8 + indexbyte2)
final static short ldc2_w = 0x14; // indexbyte1,
- // indexbyte2 ?
+ // indexbyte2 ?
// value pushes a constant
// #index from a constant pool
// (double or long) onto the
// stack (wide index is
// constructed as indexbyte1 <<
// 8 + indexbyte2)
- final static short iload = 0x15; // index ? value loads
- // an int
+ final static short iload = 0x15; // index ? value
+ // loads
+ // an int
// value from a variable #index
- final static short lload = 0x16; // index ? value load a
- // long
+ final static short lload = 0x16; // index ? value
+ // load a
+ // long
// value from a local variable
// #index
- final static short fload = 0x17; // index ? value loads a
- // float
+ final static short fload = 0x17; // index ? value
+ // loads a
+ // float
// value from a local variable
// #index
- final static short dload = 0x18; // index ? value loads a
- // double
+ final static short dload = 0x18; // index ? value
+ // loads a
+ // double
// value from a local variable
// #index
final static short aload = 0x19; // index ? objectref
- // loads a
+ // loads a
// reference onto the stack from
// a local variable #index
- final static short lload_2 = 0x20; // ? value load a long
- // value
+ final static short lload_2 = 0x20; // ? value load a
+ // long
+ // value
// from a local variable 2
- final static short lload_3 = 0x21; // ? value load a long
- // value
+ final static short lload_3 = 0x21; // ? value load a
+ // long
+ // value
// from a local variable 3
- final static short fload_0 = 0x22; // ? value loads a float
- // value
+ final static short fload_0 = 0x22; // ? value loads a
+ // float
+ // value
// from local variable 0
- final static short fload_1 = 0x23; // ? value loads a float
- // value
+ final static short fload_1 = 0x23; // ? value loads a
+ // float
+ // value
// from local variable 1
- final static short fload_2 = 0x24; // ? value loads a float
- // value
+ final static short fload_2 = 0x24; // ? value loads a
+ // float
+ // value
// from local variable 2
- final static short fload_3 = 0x25; // ? value loads a float
- // value
+ final static short fload_3 = 0x25; // ? value loads a
+ // float
+ // value
// from local variable 3
final static short dload_0 = 0x26; // ? value loads a
- // double from
+ // double from
// local variable 0
final static short dload_1 = 0x27; // ? value loads a
- // double from
+ // double from
// local variable 1
final static short dload_2 = 0x28; // ? value loads a
- // double from
+ // double from
// local variable 2
final static short dload_3 = 0x29; // ? value loads a
- // double from
+ // double from
// local variable 3
final static short faload = 0x30; // arrayref, index ?
- // value loads
+ // value loads
// a float from an array
final static short daload = 0x31; // arrayref, index ?
- // value loads
+ // value loads
// a double from an array
final static short aaload = 0x32; // arrayref, index ?
- // value loads
+ // value loads
// onto the stack a reference
// from an array
final static short baload = 0x33; // arrayref, index ?
- // value loads
+ // value loads
// a byte or Boolean value from
// an array
final static short caload = 0x34; // arrayref, index ?
- // value loads
+ // value loads
// a char from an array
final static short saload = 0x35; // arrayref, index ?
- // value load
+ // value load
// short from array
- final static short istore = 0x36; // index value ? store
- // int value
+ final static short istore = 0x36; // index value ?
+ // store
+ // int value
// into variable #index
- final static short lstore = 0x37; // index value ? store a
- // long
+ final static short lstore = 0x37; // index value ?
+ // store a
+ // long
// value in a local variable
// #index
- final static short fstore = 0x38; // index value ? stores
- // a float
+ final static short fstore = 0x38; // index value ?
+ // stores
+ // a float
// value into a local variable
// #index
- final static short dstore = 0x39; // index value ? stores
- // a double
+ final static short dstore = 0x39; // index value ?
+ // stores
+ // a double
// value into a local variable
// #index
- final static short lstore_1 = 0x40; // value ? store a long
- // value in
+ final static short lstore_1 = 0x40; // value ? store a
+ // long
+ // value in
// a local variable 1
- final static short lstore_2 = 0x41; // value ? store a long
- // value in
+ final static short lstore_2 = 0x41; // value ? store a
+ // long
+ // value in
// a local variable 2
- final static short lstore_3 = 0x42; // value ? store a long
- // value in
+ final static short lstore_3 = 0x42; // value ? store a
+ // long
+ // value in
// a local variable 3
final static short fstore_0 = 0x43; // value ? stores a
- // float value
+ // float value
// into local variable 0
final static short fstore_1 = 0x44; // value ? stores a
- // float value
+ // float value
// into local variable 1
final static short fstore_2 = 0x45; // value ? stores a
- // float value
+ // float value
// into local variable 2
final static short fstore_3 = 0x46; // value ? stores a
- // float value
+ // float value
// into local variable 3
final static short dstore_0 = 0x47; // value ? stores a
- // double into
+ // double into
// local variable 0
final static short dstore_1 = 0x48; // value ? stores a
- // double into
+ // double into
// local variable 1
final static short dstore_2 = 0x49; // value ? stores a
- // double into
+ // double into
// local variable 2
final static short lastore = 0x50; // arrayref, index,
- // value ?
+ // value ?
// store a long to an array
final static short fastore = 0x51; // arreyref, index,
- // value ?
+ // value ?
// stores a float in an array
final static short dastore = 0x52; // arrayref, index,
- // value ?
+ // value ?
// stores a double into an array
final static short aastore = 0x53; // arrayref, index,
- // value ?
+ // value ?
// stores into a reference to an
// array
final static short bastore = 0x54; // arrayref, index,
- // value ?
+ // value ?
// stores a byte or Boolean
// value into an array
final static short castore = 0x55; // arrayref, index,
- // value ?
+ // value ?
// stores a char into an array
final static short sastore = 0x56; // arrayref, index,
- // value ?
+ // value ?
// store short to array
- final static short pop = 0x57; // value ? discards the
- // top
+ final static short pop = 0x57; // value ? discards
+ // the
+ // top
// value on the stack
- final static short pop2 = 0x58; // {value2, value1} ?
- // discards
+ final static short pop2 = 0x58; // {value2, value1}
+ // ?
+ // discards
// the top two values on the
// stack (or one value, if it is
// a double or long)
- final static short dup = 0x59; // value ? value, value
+ final static short dup = 0x59; // value ? value,
+ // value
// duplicates the value on top
// of the stack
final static short iadd = 0x60; // value1, value2 ?
- // result adds
+ // result adds
// two ints together
final static short ladd = 0x61; // value1, value2 ?
- // result add
+ // result add
// two longs
final static short fadd = 0x62; // value1, value2 ?
- // result adds
+ // result adds
// two floats
final static short dadd = 0x63; // value1, value2 ?
- // result adds
+ // result adds
// two doubles
final static short isub = 0x64; // value1, value2 ?
- // result int
+ // result int
// subtract
final static short lsub = 0x65; // value1, value2 ?
- // result
+ // result
// subtract two longs
final static short fsub = 0x66; // value1, value2 ?
- // result
+ // result
// subtracts two floats
final static short dsub = 0x67; // value1, value2 ?
- // result
+ // result
// subtracts a double from
// another
final static short imul = 0x68; // value1, value2 ?
- // result
+ // result
// multiply two integers
final static short lmul = 0x69; // value1, value2 ?
- // result
+ // result
// multiplies two longs
final static short irem = 0x70; // value1, value2 ?
- // result
+ // result
// logical int remainder
final static short lrem = 0x71; // value1, value2 ?
- // result
+ // result
// remainder of division of two
// longs
final static short frem = 0x72; // value1, value2 ?
- // result gets
+ // result gets
// the remainder from a division
// between two floats
final static short drem = 0x73; // value1, value2 ?
- // result gets
+ // result gets
// the remainder from a division
// between two doubles
- final static short ineg = 0x74; // value ? result negate
- // int
+ final static short ineg = 0x74; // value ? result
+ // negate
+ // int
final static short lneg = 0x75; // value ? result
- // negates a long
+ // negates a long
final static short fneg = 0x76; // value ? result
- // negates a
+ // negates a
// float
final static short dneg = 0x77; // value ? result
- // negates a
+ // negates a
// double
final static short ishl = 0x78; // value1, value2 ?
- // result int
+ // result int
// shift left
final static short lshl = 0x79; // value1, value2 ?
- // result
+ // result
// bitwise shift left of a long
// value1 by value2 positions
final static short ior = 0x80; // value1, value2 ?
- // result
+ // result
// logical int or
final static short lor = 0x81; // value1, value2 ?
- // result
+ // result
// bitwise or of two longs
final static short ixor = 0x82; // value1, value2 ?
- // result int
+ // result int
// xor
final static short lxor = 0x83; // value1, value2 ?
- // result
+ // result
// bitwise exclusive or of two
// longs
final static short iinc = 0x84; // index, const [No
- // change]
+ // change]
// increment local variable
// #index by signed byte const
final static short i2l = 0x85; // value ? result
- // converts an
+ // converts an
// int into a long
final static short i2f = 0x86; // value ? result
- // converts an
+ // converts an
// int into a float
final static short i2d = 0x87; // value ? result
- // converts an
+ // converts an
// int into a double
final static short l2i = 0x88; // value ? result
- // converts a
+ // converts a
// long to an int
final static short l2f = 0x89; // value ? result
- // converts a
+ // converts a
// long to a float
final static short d2f = 0x90; // value ? result
- // converts a
+ // converts a
// double to a float
final static short i2b = 0x91; // value ? result
- // converts an
+ // converts an
// int into a byte
final static short i2c = 0x92; // value ? result
- // converts an
+ // converts an
// int into a character
final static short i2s = 0x93; // value ? result
- // converts an
+ // converts an
// int into a short
final static short lcmp = 0x94; // value1, value2 ?
- // result
+ // result
// compares two longs values
final static short fcmpl = 0x95; // value1, value2 ?
- // result
+ // result
// compares two floats
final static short fcmpg = 0x96; // value1, value2 ?
- // result
+ // result
// compares two floats
final static short dcmpl = 0x97; // value1, value2 ?
- // result
+ // result
// compares two doubles
final static short dcmpg = 0x98; // value1, value2 ?
- // result
+ // result
// compares two doubles
final static short ifeq = 0x99; // branchbyte1,
- // branchbyte2
+ // branchbyte2
// value ? if value is 0, branch
// to instruction at
// branchoffset (signed short
// constructed from unsigned
// bytes branchbyte1 << 8 +
// branchbyte2)
- final static short lconst_1 = 0x0a; // ? 1L pushes the long
- // 1 onto
+ final static short lconst_1 = 0x0a; // ? 1L pushes the
+ // long
+ // 1 onto
// the stack
- final static short fconst_0 = 0x0b; // ? 0.0f pushes 0.0f on
- // the
+ final static short fconst_0 = 0x0b; // ? 0.0f pushes
+ // 0.0f on
+ // the
// stack
- final static short fconst_1 = 0x0c; // ? 1.0f pushes 1.0f on
- // the
+ final static short fconst_1 = 0x0c; // ? 1.0f pushes
+ // 1.0f on
+ // the
// stack
- final static short fconst_2 = 0x0d; // ? 2.0f pushes 2.0f on
- // the
+ final static short fconst_2 = 0x0d; // ? 2.0f pushes
+ // 2.0f on
+ // the
// stack
final static short dconst_0 = 0x0e; // ? 0.0 pushes the
- // constant 0.0
+ // constant 0.0
// onto the stack
final static short dconst_1 = 0x0f; // ? 1.0 pushes the
- // constant 1.0
+ // constant 1.0
// onto the stack
- final static short iload_0 = 0x1a; // ? value loads an int
- // value
+ final static short iload_0 = 0x1a; // ? value loads an
+ // int
+ // value
// from variable 0
- final static short iload_1 = 0x1b; // ? value loads an int
- // value
+ final static short iload_1 = 0x1b; // ? value loads an
+ // int
+ // value
// from variable 1
- final static short iload_2 = 0x1c; // ? value loads an int
- // value
+ final static short iload_2 = 0x1c; // ? value loads an
+ // int
+ // value
// from variable 2
- final static short iload_3 = 0x1d; // ? value loads an int
- // value
+ final static short iload_3 = 0x1d; // ? value loads an
+ // int
+ // value
// from variable 3
- final static short lload_0 = 0x1e; // ? value load a long
- // value
+ final static short lload_0 = 0x1e; // ? value load a
+ // long
+ // value
// from a local variable 0
- final static short lload_1 = 0x1f; // ? value load a long
- // value
+ final static short lload_1 = 0x1f; // ? value load a
+ // long
+ // value
// from a local variable 1
- final static short aload_0 = 0x2a; // ? objectref loads a
- // reference
+ final static short aload_0 = 0x2a; // ? objectref loads
+ // a
+ // reference
// onto the stack from local
// variable 0
- final static short aload_1 = 0x2b; // ? objectref loads a
- // reference
+ final static short aload_1 = 0x2b; // ? objectref loads
+ // a
+ // reference
// onto the stack from local
// variable 1
- final static short aload_2 = 0x2c; // ? objectref loads a
- // reference
+ final static short aload_2 = 0x2c; // ? objectref loads
+ // a
+ // reference
// onto the stack from local
// variable 2
- final static short aload_3 = 0x2d; // ? objectref loads a
- // reference
+ final static short aload_3 = 0x2d; // ? objectref loads
+ // a
+ // reference
// onto the stack from local
// variable 3
final static short iaload = 0x2e; // arrayref, index ?
- // value loads
+ // value loads
// an int from an array
final static short laload = 0x2f; // arrayref, index ?
- // value load
+ // value load
// a long from an array
final static short astore = 0x3a; // index objectref ?
- // stores a
+ // stores a
// reference into a local
// variable #index
final static short istore_0 = 0x3b; // value ? store int
- // value into
+ // value into
// variable 0
final static short istore_1 = 0x3c; // value ? store int
- // value into
+ // value into
// variable 1
final static short istore_2 = 0x3d; // value ? store int
- // value into
+ // value into
// variable 2
final static short istore_3 = 0x3e; // value ? store int
- // value into
+ // value into
// variable 3
- final static short lstore_0 = 0x3f; // value ? store a long
- // value in
+ final static short lstore_0 = 0x3f; // value ? store a
+ // long
+ // value in
// a local variable 0
final static short dstore_3 = 0x4a; // value ? stores a
- // double into
+ // double into
// local variable 3
- final static short astore_0 = 0x4b; // objectref ? stores a
+ final static short astore_0 = 0x4b; // objectref ?
+ // stores a
// reference into local variable
// 0
- final static short astore_1 = 0x4c; // objectref ? stores a
+ final static short astore_1 = 0x4c; // objectref ?
+ // stores a
// reference into local variable
// 1
- final static short astore_2 = 0x4d; // objectref ? stores a
+ final static short astore_2 = 0x4d; // objectref ?
+ // stores a
// reference into local variable
// 2
- final static short astore_3 = 0x4e; // objectref ? stores a
+ final static short astore_3 = 0x4e; // objectref ?
+ // stores a
// reference into local variable
// 3
final static short iastore = 0x4f; // arrayref, index,
- // value ?
+ // value ?
// stores an int into an array
final static short dup_x1 = 0x5a; // value2, value1 ?
- // value1,
+ // value1,
// value2, value1 inserts a copy
// of the top value into the
// stack two values from the top
final static short dup_x2 = 0x5b; // value3, value2,
- // value1 ?
+ // value1 ?
// value1, value3, value2,
// value1 inserts a copy of the
// top value into the stack two
@@ -448,8 +495,9 @@
// value3, too) or three values
// (if value2 is neither double
// nor long) from the top
- final static short dup2 = 0x5c; // {value2, value1} ?
- // {value2,
+ final static short dup2 = 0x5c; // {value2, value1}
+ // ?
+ // {value2,
// value1}, {value2, value1}
// duplicate top two stack words
// (two values, if value1 is not
@@ -457,85 +505,85 @@
// value, if value1 is double or
// long)
final static short dup2_x1 = 0x5d; // value3, {value2,
- // value1} ?
+ // value1} ?
// {value2, value1}, value3,
// {value2, value1} duplicate
// two words and insert beneath
// third word (see explanation
// above)
final static short dup2_x2 = 0x5e; // {value4, value3},
- // {value2,
+ // {value2,
// value1} ? {value2, value1},
// {value4, value3}, {value2,
// value1} duplicate two words
// and insert beneath fourth
// word
final static short swap = 0x5f; // value2, value1 ?
- // value1,
+ // value1,
// value2 swaps two top words on
// the stack (note that value1
// and value2 must not be double
// or long)
final static short fmul = 0x6a; // value1, value2 ?
- // result
+ // result
// multiplies two floats
final static short dmul = 0x6b; // value1, value2 ?
- // result
+ // result
// multiplies two doubles
final static short idiv = 0x6c; // value1, value2 ?
- // result
+ // result
// divides two integers
final static short ldiv = 0x6d; // value1, value2 ?
- // result
+ // result
// divide two longs
final static short fdiv = 0x6e; // value1, value2 ?
- // result
+ // result
// divides two floats
final static short ddiv = 0x6f; // value1, value2 ?
- // result
+ // result
// divides two doubles
final static short ishr = 0x7a; // value1, value2 ?
- // result int
+ // result int
// shift right
final static short lshr = 0x7b; // value1, value2 ?
- // result
+ // result
// bitwise shift right of a long
// value1 by value2 positions
final static short iushr = 0x7c; // value1, value2 ?
- // result int
+ // result int
// shift right
final static short lushr = 0x7d; // value1, value2 ?
- // result
+ // result
// bitwise shift right of a long
// value1 by value2 positions,
// unsigned
final static short iand = 0x7e; // value1, value2 ?
- // result
+ // result
// performs a logical and on two
// integers
final static short land = 0x7f; // value1, value2 ?
- // result
+ // result
// bitwise and of two longs
final static short l2d = 0x8a; // value ? result
- // converts a
+ // converts a
// long to a double
final static short f2i = 0x8b; // value ? result
- // converts a
+ // converts a
// float to an int
final static short f2l = 0x8c; // value ? result
- // converts a
+ // converts a
// float to a long
final static short f2d = 0x8d; // value ? result
- // converts a
+ // converts a
// float to a double
final static short d2i = 0x8e; // value ? result
- // converts a
+ // converts a
// double to an int
final static short d2l = 0x8f; // value ? result
- // converts a
+ // converts a
// double to a long
final static short ifne = 0x9a; // branchbyte1,
- // branchbyte2
+ // branchbyte2
// value ? if value is not 0,
// branch to instruction at
// branchoffset (signed short
@@ -543,7 +591,7 @@
// bytes branchbyte1 << 8 +
// branchbyte2)
final static short iflt = 0x9b; // branchbyte1,
- // branchbyte2
+ // branchbyte2
// value ? if value is less than
// 0, branch to instruction at
// branchoffset (signed short
@@ -551,7 +599,7 @@
// bytes branchbyte1 << 8 +
// branchbyte2)
final static short ifge = 0x9c; // branchbyte1,
- // branchbyte2
+ // branchbyte2
// value ? if value is greater
// than or equal to 0, branch to
// instruction at branchoffset
@@ -560,7 +608,7 @@
// branchbyte1 << 8 +
// branchbyte2)
final static short ifgt = 0x9d; // branchbyte1,
- // branchbyte2
+ // branchbyte2
// value ? if value is greater
// than 0, branch to instruction
// at branchoffset (signed short
@@ -568,7 +616,7 @@
// bytes branchbyte1 << 8 +
// branchbyte2)
final static short ifle = 0x9e; // branchbyte1,
- // branchbyte2
+ // branchbyte2
// value ? if value is less than
// or equal to 0, branch to
// instruction at branchoffset
@@ -577,7 +625,7 @@
// branchbyte1 << 8 +
// branchbyte2)
final static short if_icmpeq = 0x9f; // branchbyte1,
- // branchbyte2
+ // branchbyte2
// value1, value2 ? if ints are
// equal, branch to instruction
// at branchoffset (signed short
@@ -585,7 +633,7 @@
// bytes branchbyte1 << 8 +
// branchbyte2)
final static short if_icmpne = 0xa0; // branchbyte1,
- // branchbyte2
+ // branchbyte2
// value1, value2 ? if ints are
// not equal, branch to
// instruction at branchoffset
@@ -594,7 +642,7 @@
// branchbyte1 << 8 +
// branchbyte2)
final static short if_icmplt = 0xa1; // branchbyte1,
- // branchbyte2
+ // branchbyte2
// value1, value2 ? if value1 is
// less than value2, branch to
// instruction at branchoffset
@@ -603,7 +651,7 @@
// branchbyte1 << 8 +
// branchbyte2)
final static short if_icmpge = 0xa2; // branchbyte1,
- // branchbyte2
+ // branchbyte2
// value1, value2 ? if value1 is
// greater than or equal to
// value2, branch to instruction
@@ -612,7 +660,7 @@
// bytes branchbyte1 << 8 +
// branchbyte2)
final static short if_icmpgt = 0xa3; // branchbyte1,
- // branchbyte2
+ // branchbyte2
// value1, value2 ? if value1 is
// greater than value2, branch
// to instruction at
@@ -621,7 +669,7 @@
// bytes branchbyte1 << 8 +
// branchbyte2)
final static short if_icmple = 0xa4; // branchbyte1,
- // branchbyte2
+ // branchbyte2
// value1, value2 ? if value1 is
// less than or equal to value2,
// branch to instruction at
@@ -630,7 +678,7 @@
// bytes branchbyte1 << 8 +
// branchbyte2)
final static short if_acmpeq = 0xa5; // branchbyte1,
- // branchbyte2
+ // branchbyte2
// value1, value2 ? if
// references are equal, branch
// to instruction at
@@ -639,7 +687,7 @@
// bytes branchbyte1 << 8 +
// branchbyte2)
final static short if_acmpne = 0xa6; // branchbyte1,
- // branchbyte2
+ // branchbyte2
// value1, value2 ? if
// references are not equal,
// branch to instruction at
@@ -648,7 +696,7 @@
// bytes branchbyte1 << 8 +
// branchbyte2)
final static short goto_ = 0xa7; // branchbyte1,
- // branchbyte2 [no
+ // branchbyte2 [no
// change] goes to another
// instruction at branchoffset
// (signed short constructed
@@ -656,7 +704,7 @@
// branchbyte1 << 8 +
// branchbyte2)
final static short jsr = 0xa8; // branchbyte1,
- // branchbyte2 ?
+ // branchbyte2 ?
// address jump to subroutine at
// branchoffset (signed short
// constructed from unsigned
@@ -664,12 +712,13 @@
// branchbyte2) and place the
// return address on the stack
final static short ret = 0xa9; // index [No change]
- // continue
+ // continue
// execution from address taken
// from a local variable #index
// (the asymmetry with jsr is
// intentional)
- final static short tableswitch = 0xaa; // [0-3 bytes padding],
+ final static short tableswitch = 0xaa; // [0-3 bytes
+ // padding],
// defaultbyte1, defaultbyte2,
// defaultbyte3, defaultbyte4,
// lowbyte1, lowbyte2, lowbyte3,
@@ -679,7 +728,8 @@
// index ? continue execution
// from an address in the table
// at offset index
- final static short lookupswitch = 0xab; // <0-3 bytes padding>,
+ final static short lookupswitch = 0xab; // <0-3 bytes
+ // padding>,
// defaultbyte1, defaultbyte2,
// defaultbyte3, defaultbyte4,
// npairs1, npairs2, npairs3,
@@ -690,32 +740,34 @@
// execution continues from the
// instruction at that address
final static short ireturn = 0xac; // value ? [empty]
- // returns an
+ // returns an
// integer from a method
final static short lreturn = 0xad; // value ? [empty]
- // returns a
+ // returns a
// long value
final static short freturn = 0xae; // value ? [empty]
- // returns a
+ // returns a
// float
final static short dreturn = 0xaf; // value ? [empty]
- // returns a
+ // returns a
// double from a method
- final static short areturn = 0xb0; // objectref ? [empty]
- // returns a
+ final static short areturn = 0xb0; // objectref ?
+ // [empty]
+ // returns a
// reference from a method
- final static short return_ = 0xb1; // ? [empty] return void
- // from
+ final static short return_ = 0xb1; // ? [empty] return
+ // void
+ // from
// method
final static short getstatic = 0xb2; // index1, index2 ?
- // value gets a
+ // value gets a
// static field value of a
// class, where the field is
// identified by field reference
// in the constant pool index
// (index1 << 8 + index2)
final static short putstatic = 0xb3; // indexbyte1,
- // indexbyte2 value
+ // indexbyte2 value
// ? set static field to value
// in a class, where the field
// is identified by a field
@@ -723,7 +775,7 @@
// pool (indexbyte1 << 8 +
// indexbyte2)
final static short getfield = 0xb4; // index1, index2
- // objectref ?
+ // objectref ?
// value gets a field value of
// an object objectref, where
// the field is identified by
@@ -731,7 +783,7 @@
// constant pool index (index1
// << 8 + index2)
final static short putfield = 0xb5; // indexbyte1,
- // indexbyte2
+ // indexbyte2
// objectref, value ? set field
// to value in an object
// objectref, where the field is
@@ -740,7 +792,7 @@
// pool (indexbyte1 << 8 +
// indexbyte2)
final static short invokevirtual = 0xb6; // indexbyte1,
- // indexbyte2
+ // indexbyte2
// objectref, [arg1, arg2, ...]
// ? invoke virtual method on
// object objectref, where the
@@ -749,7 +801,7 @@
// constant pool (indexbyte1 <<
// 8 + indexbyte2)
final static short invokespecial = 0xb7; // indexbyte1,
- // indexbyte2
+ // indexbyte2
// objectref, [arg1, arg2, ...]
// ? invoke instance method on
// object objectref, where the
@@ -758,7 +810,7 @@
// constant pool (indexbyte1 <<
// 8 + indexbyte2)
final static short invokestatic = 0xb8; // indexbyte1,
- // indexbyte2 [arg1,
+ // indexbyte2 [arg1,
// arg2, ...] ? invoke a static
// method, where the method is
// identified by method
@@ -766,7 +818,7 @@
// pool (indexbyte1 << 8 +
// indexbyte2)
final static short invokeinterface = 0xb9; // indexbyte1,
- // indexbyte2,
+ // indexbyte2,
// count, 0 objectref, [arg1,
// arg2, ...] ? invokes an
// interface method on object
@@ -777,22 +829,22 @@
// pool (indexbyte1 << 8 +
// indexbyte2)
final static short xxxunusedxxx = 0xba; // this opcode is
- // reserved "for
+ // reserved "for
// historical reasons"
final static short new_ = 0xbb; // indexbyte1,
- // indexbyte2 ?
+ // indexbyte2 ?
// objectref creates new object
// of type identified by class
// reference in constant pool
// index (indexbyte1 << 8 +
// indexbyte2)
final static short newarray = 0xbc; // atype count ?
- // arrayref
+ // arrayref
// creates new array with count
// elements of primitive type
// identified by atype
final static short anewarray = 0xbd; // indexbyte1,
- // indexbyte2 count
+ // indexbyte2 count
// ? arrayref creates a new
// array of references of length
// count and component type
@@ -801,16 +853,17 @@
// << 8 + indexbyte2) in the
// constant pool
final static short arraylength = 0xbe; // arrayref ? length
- // gets the
+ // gets the
// length of an array
- final static short athrow = 0xbf; // objectref ? [empty],
+ final static short athrow = 0xbf; // objectref ?
+ // [empty],
// objectref throws an error or
// exception (notice that the
// rest of the stack is cleared,
// leaving only a reference to
// the Throwable)
final static short checkcast = 0xc0; // indexbyte1,
- // indexbyte2
+ // indexbyte2
// objectref ? objectref checks
// whether an objectref is of a
// certain type, the class
@@ -819,7 +872,7 @@
// (indexbyte1 << 8 +
// indexbyte2)
final static short instanceof_ = 0xc1; // indexbyte1,
- // indexbyte2
+ // indexbyte2
// objectref ? result determines
// if an object objectref is of
// a given type, identified by
@@ -827,19 +880,20 @@
// constant pool (indexbyte1 <<
// 8 + indexbyte2)
final static short monitorenter = 0xc2; // objectref ? enter
- // monitor for
+ // monitor for
// object ("grab the lock" -
// start of synchronized()
// section)
final static short monitorexit = 0xc3; // objectref ? exit
- // monitor for
+ // monitor for
// object ("release the lock" -
// end of synchronized()
// section)
- final static short wide = 0xc4; // opcode, indexbyte1,
+ final static short wide = 0xc4; // opcode,
+ // indexbyte1,
// indexbyte2
final static short multianewarray = 0xc5; // indexbyte1,
- // indexbyte2,
+ // indexbyte2,
// dimensions count1,
// [count2,...] ? arrayref
// create a new array of
@@ -852,7 +906,7 @@
// each dimension is identified
// by count1, [count2, etc]
final static short ifnull = 0xc6; // branchbyte1,
- // branchbyte2
+ // branchbyte2
// value ? if value is null,
// branch to instruction at
// branchoffset (signed short
@@ -860,7 +914,7 @@
// bytes branchbyte1 << 8 +
// branchbyte2)
final static short ifnonnull = 0xc7; // branchbyte1,
- // branchbyte2
+ // branchbyte2
// value ? if value is not null,
// branch to instruction at
// branchoffset (signed short
@@ -868,7 +922,7 @@
// bytes branchbyte1 << 8 +
// branchbyte2)
final static short goto_w = 0xc8; // branchbyte1,
- // branchbyte2,
+ // branchbyte2,
// branchbyte3, branchbyte4 [no
// change] goes to another
// instruction at branchoffset
@@ -878,7 +932,7 @@
// branchbyte3 << 8 +
// branchbyte4)
final static short jsr_w = 0xc9; // branchbyte1,
- // branchbyte2,
+ // branchbyte2,
// branchbyte3, branchbyte4 ?
// address jump to subroutine at
// branchoffset (signed int
@@ -889,7 +943,7 @@
// branchbyte4) and place the
// return address on the stack
final static short breakpoint = 0xca; // reserved for
- // breakpoints in
+ // breakpoints in
// Java debuggers; should not
// appear in any class file
final static short impdep1 = 0xfe; // reserved for
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/Packages.java b/bundleplugin/src/main/java/aQute/lib/osgi/Packages.java
index 09e8305..fae4597 100644
--- a/bundleplugin/src/main/java/aQute/lib/osgi/Packages.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/Packages.java
@@ -5,21 +5,20 @@
import aQute.lib.osgi.Descriptors.PackageRef;
import aQute.libg.header.*;
-public class Packages implements Map<PackageRef, Attrs> {
- private LinkedHashMap<PackageRef, Attrs> map;
- static Map<PackageRef, Attrs> EMPTY = Collections.emptyMap();
+public class Packages implements Map<PackageRef,Attrs> {
+ private LinkedHashMap<PackageRef,Attrs> map;
+ static Map<PackageRef,Attrs> EMPTY = Collections.emptyMap();
public Packages(Packages other) {
if (other.map != null) {
- map = new LinkedHashMap<Descriptors.PackageRef, Attrs>(other.map);
+ map = new LinkedHashMap<Descriptors.PackageRef,Attrs>(other.map);
}
}
- public Packages() {
- }
+ public Packages() {}
public void clear() {
- if(map!=null)
+ if (map != null)
map.clear();
}
@@ -30,7 +29,8 @@
return map.containsKey(name);
}
- @Deprecated public boolean containsKey(Object name) {
+ @Deprecated
+ public boolean containsKey(Object name) {
assert name instanceof PackageRef;
if (map == null)
return false;
@@ -45,7 +45,8 @@
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;
@@ -53,14 +54,15 @@
return map.containsValue((Attrs) value);
}
- public Set<java.util.Map.Entry<PackageRef, Attrs>> entrySet() {
+ public Set<java.util.Map.Entry<PackageRef,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 PackageRef;
if (map == null)
return null;
@@ -98,28 +100,29 @@
public Attrs put(PackageRef key, Attrs value) {
if (map == null)
- map = new LinkedHashMap<PackageRef, Attrs>();
+ map = new LinkedHashMap<PackageRef,Attrs>();
return map.put(key, value);
}
- public void putAll(Map<? extends PackageRef, ? extends Attrs> map) {
+ public void putAll(Map< ? extends PackageRef, ? extends Attrs> map) {
if (this.map == null)
if (map.isEmpty())
return;
else
- this.map = new LinkedHashMap<PackageRef, Attrs>();
+ this.map = new LinkedHashMap<PackageRef,Attrs>();
this.map.putAll(map);
}
public void putAllIfAbsent(Map<PackageRef, ? extends Attrs> map) {
- for(Map.Entry<PackageRef, ? extends Attrs> entry : map.entrySet() ) {
- if ( !containsKey(entry.getKey()))
+ for (Map.Entry<PackageRef, ? extends Attrs> entry : map.entrySet()) {
+ if (!containsKey(entry.getKey()))
put(entry.getKey(), entry.getValue());
}
}
-
- @Deprecated public Attrs remove(Object var0) {
+
+ @Deprecated
+ public Attrs remove(Object var0) {
assert var0 instanceof PackageRef;
if (map == null)
return null;
@@ -150,7 +153,7 @@
if (map == null)
return null;
- for (Map.Entry<PackageRef, Attrs> pr : map.entrySet()) {
+ for (Map.Entry<PackageRef,Attrs> pr : map.entrySet()) {
if (pr.getKey().getFQN().equals(s))
return pr.getValue();
}
@@ -161,7 +164,7 @@
if (map == null)
return null;
- for (Map.Entry<PackageRef, Attrs> pr : map.entrySet()) {
+ for (Map.Entry<PackageRef,Attrs> pr : map.entrySet()) {
if (pr.getKey().getBinary().equals(s))
pr.getValue();
}
@@ -184,7 +187,7 @@
public void append(StringBuilder sb) {
String del = "";
- for (Map.Entry<PackageRef, Attrs> s : entrySet()) {
+ for (Map.Entry<PackageRef,Attrs> s : entrySet()) {
sb.append(del);
sb.append(s.getKey());
if (!s.getValue().isEmpty()) {
@@ -196,11 +199,11 @@
}
public void merge(PackageRef ref, boolean unique, Attrs... attrs) {
- if ( unique ) {
- while ( containsKey(ref))
+ if (unique) {
+ while (containsKey(ref))
ref = ref.getDuplicate();
}
-
+
Attrs org = put(ref);
for (Attrs a : attrs) {
if (a != null)
@@ -210,21 +213,20 @@
public Attrs get(PackageRef packageRef, Attrs deflt) {
Attrs mine = get(packageRef);
- if ( mine!=null)
+ if (mine != null)
return mine;
-
+
return deflt;
}
-
@Deprecated
public boolean equals(Object other) {
return super.equals(other);
}
-
+
@Deprecated
public int hashCode() {
return super.hashCode();
}
-
+
}
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/PreprocessResource.java b/bundleplugin/src/main/java/aQute/lib/osgi/PreprocessResource.java
index f003abc..8b3f79e 100644
--- a/bundleplugin/src/main/java/aQute/lib/osgi/PreprocessResource.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/PreprocessResource.java
@@ -3,42 +3,43 @@
import java.io.*;
public class PreprocessResource extends AbstractResource {
- final Resource resource;
- final Processor processor;
+ final Resource resource;
+ final Processor processor;
- public PreprocessResource(Processor processor, Resource r) {
- super(r.lastModified());
- this.processor = processor;
- this.resource = r;
- setExtra(resource.getExtra());
- }
+ public PreprocessResource(Processor processor, Resource r) {
+ super(r.lastModified());
+ this.processor = processor;
+ this.resource = r;
+ setExtra(resource.getExtra());
+ }
- protected byte[] getBytes() throws Exception {
- ByteArrayOutputStream bout = new ByteArrayOutputStream(2000);
- OutputStreamWriter osw = new OutputStreamWriter(bout, Constants.DEFAULT_CHARSET);
- PrintWriter pw = new PrintWriter(osw);
- InputStream in = null;
- BufferedReader rdr = null;
- try {
+ protected byte[] getBytes() throws Exception {
+ ByteArrayOutputStream bout = new ByteArrayOutputStream(2000);
+ OutputStreamWriter osw = new OutputStreamWriter(bout, Constants.DEFAULT_CHARSET);
+ PrintWriter pw = new PrintWriter(osw);
+ InputStream in = null;
+ BufferedReader rdr = null;
+ try {
in = resource.openInputStream();
- rdr = new BufferedReader(new InputStreamReader(in,"UTF8"));
- String line = rdr.readLine();
- while (line != null) {
- line = processor.getReplacer().process(line);
- pw.println(line);
- line = rdr.readLine();
- }
- pw.flush();
- byte [] data= bout.toByteArray();
- return data;
-
- } finally {
+ rdr = new BufferedReader(new InputStreamReader(in, "UTF8"));
+ String line = rdr.readLine();
+ while (line != null) {
+ line = processor.getReplacer().process(line);
+ pw.println(line);
+ line = rdr.readLine();
+ }
+ pw.flush();
+ byte[] data = bout.toByteArray();
+ return data;
+
+ }
+ finally {
if (rdr != null) {
rdr.close();
}
if (in != null) {
in.close();
}
- }
- }
+ }
+ }
}
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/Processor.java b/bundleplugin/src/main/java/aQute/lib/osgi/Processor.java
index 655ce4d..ab1cf10 100755
--- a/bundleplugin/src/main/java/aQute/lib/osgi/Processor.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/Processor.java
@@ -96,7 +96,7 @@
getInfo(processor, "");
}
- private <T> void addAll(List<String> to, List<? extends T> from, String prefix) {
+ private <T> void addAll(List<String> to, List< ? extends T> from, String prefix) {
for (T x : from) {
to.add(prefix + x);
}
@@ -152,8 +152,7 @@
p.signal();
}
- public void signal() {
- }
+ public void signal() {}
public List<String> getWarnings() {
return warnings;
@@ -250,9 +249,8 @@
/**
* Return a list of plugins. Plugins are defined with the -plugin command.
* They are class names, optionally associated with attributes. Plugins can
- * implement the Plugin interface to see these attributes.
- *
- * Any object can be a plugin.
+ * implement the Plugin interface to see these attributes. Any object can be
+ * a plugin.
*
* @return
*/
@@ -295,7 +293,7 @@
CL loader = getLoader();
// First add the plugin-specific paths from their path: directives
- for (Entry<String, Attrs> entry : plugins.entrySet()) {
+ for (Entry<String,Attrs> entry : plugins.entrySet()) {
String key = removeDuplicateMarker(entry.getKey());
String path = entry.getValue().get(PATH_DIRECTIVE);
if (path != null) {
@@ -305,9 +303,9 @@
File f = getFile(p).getAbsoluteFile();
loader.add(f.toURI().toURL());
}
- } catch (Exception e) {
- error("Problem adding path %s to loader for plugin %s. Exception: (%s)", path,
- key, e);
+ }
+ catch (Exception e) {
+ error("Problem adding path %s to loader for plugin %s. Exception: (%s)", path, key, e);
}
}
}
@@ -320,14 +318,15 @@
try {
File f = getFile(path).getAbsoluteFile();
loader.add(f.toURI().toURL());
- } catch (Exception e) {
+ }
+ catch (Exception e) {
error("Problem adding path %s from global plugin path. Exception: %s", path, e);
}
}
}
// Load the plugins
- for (Entry<String, Attrs> entry : plugins.entrySet()) {
+ for (Entry<String,Attrs> entry : plugins.entrySet()) {
String key = entry.getKey();
try {
@@ -339,11 +338,12 @@
key = removeDuplicateMarker(key);
try {
- Class<?> c = (Class<?>) loader.loadClass(key);
+ Class< ? > c = (Class< ? >) loader.loadClass(key);
Object plugin = c.newInstance();
customize(plugin, entry.getValue());
list.add(plugin);
- } catch (Throwable t) {
+ }
+ catch (Throwable t) {
// We can defer the error if the plugin specifies
// a command name. In that case, we'll verify that
// a bnd file does not contain any references to a
@@ -358,7 +358,8 @@
missingCommand.addAll(cs);
}
}
- } catch (Throwable e) {
+ }
+ catch (Throwable e) {
error("Problem loading the plugin: %s exception: (%s)", key, e);
}
}
@@ -420,12 +421,12 @@
return new TreeSet<T>();
}
- public static <K, V> Map<K, V> newMap() {
- return new LinkedHashMap<K, V>();
+ public static <K, V> Map<K,V> newMap() {
+ return new LinkedHashMap<K,V>();
}
- public static <K, V> Map<K, V> newHashMap() {
- return new LinkedHashMap<K, V>();
+ public static <K, V> Map<K,V> newHashMap() {
+ return new LinkedHashMap<K,V>();
}
public <T> List<T> newList(Collection<T> t) {
@@ -436,15 +437,16 @@
return new TreeSet<T>(t);
}
- public <K, V> Map<K, V> newMap(Map<K, V> t) {
- return new LinkedHashMap<K, V>(t);
+ public <K, V> Map<K,V> newMap(Map<K,V> t) {
+ return new LinkedHashMap<K,V>(t);
}
public void close() {
for (Closeable c : toBeClosed) {
try {
c.close();
- } catch (IOException e) {
+ }
+ catch (IOException e) {
// Who cares?
}
}
@@ -482,7 +484,8 @@
try {
Properties properties = loadProperties(file);
mergeProperties(properties, override);
- } catch (Exception e) {
+ }
+ catch (Exception e) {
error("Error loading properties file: " + file);
}
} else {
@@ -494,7 +497,7 @@
}
public void mergeProperties(Properties properties, boolean override) {
- for (Enumeration<?> e = properties.propertyNames(); e.hasMoreElements();) {
+ for (Enumeration< ? > e = properties.propertyNames(); e.hasMoreElements();) {
String key = (String) e.nextElement();
String value = properties.getProperty(key);
if (override || !getProperties().containsKey(key))
@@ -513,8 +516,8 @@
setProperties(p);
}
- public void addProperties(Map<?, ?> properties) {
- for (Entry<?, ?> entry : properties.entrySet()) {
+ public void addProperties(Map< ? , ? > properties) {
+ for (Entry< ? , ? > entry : properties.entrySet()) {
setProperty(entry.getKey().toString(), entry.getValue() + "");
}
}
@@ -561,11 +564,11 @@
try {
File file = getFile(ubase, value).getAbsoluteFile();
if (!file.isFile() && fileMustExist) {
- error("Included file " + file
- + (file.exists() ? " does not exist" : " is directory"));
+ error("Included file " + file + (file.exists() ? " does not exist" : " is directory"));
} else
doIncludeFile(file, overwrite, p);
- } catch (Exception e) {
+ }
+ catch (Exception e) {
if (fileMustExist)
error("Error in processing included file: " + value, e);
}
@@ -610,10 +613,10 @@
doIncludes(file.getParentFile(), sub);
// make sure we do not override properties
- for (Map.Entry<?, ?> entry : sub.entrySet()) {
+ for (Map.Entry< ? , ? > entry : sub.entrySet()) {
String key = (String) entry.getKey();
String value = (String) entry.getValue();
-
+
if (overwrite || !target.containsKey(key)) {
target.setProperty(key, value);
} else if (extensionName != null) {
@@ -622,7 +625,8 @@
target.setProperty(extensionKey, value);
}
}
- } finally {
+ }
+ finally {
IO.close(in);
}
}
@@ -645,8 +649,7 @@
if (changed)
break;
- changed |= !file.exists()
- || updateModified(file.lastModified(), "include file: " + file);
+ changed |= !file.exists() || updateModified(file.lastModified(), "include file: " + file);
}
}
@@ -667,8 +670,7 @@
propertiesChanged();
}
- public void propertiesChanged() {
- }
+ public void propertiesChanged() {}
/**
* Set the properties by file. Setting the properties this way will also set
@@ -705,7 +707,8 @@
error("No such properties file: " + propertiesFile);
}
}
- } catch (IOException e) {
+ }
+ catch (IOException e) {
error("Could not load properties " + propertiesFile);
}
}
@@ -729,11 +732,11 @@
* @param deflt
* @return
*/
-
+
public String getUnprocessedProperty(String key, String deflt) {
return getProperties().getProperty(key, deflt);
}
-
+
/**
* Get a property with preprocessing it with a proper default
*
@@ -802,7 +805,8 @@
try {
Properties p = loadProperties(in, file.getAbsolutePath());
return p;
- } finally {
+ }
+ finally {
in.close();
}
}
@@ -818,7 +822,8 @@
Properties p = new Properties();
p.load(in);
return replaceAll(p, "\\$\\{\\.\\}", name);
- } catch (Exception e) {
+ }
+ catch (Exception e) {
error("Error during loading properties file: " + name + ", error:" + e);
return new Properties();
}
@@ -832,8 +837,8 @@
public static Properties replaceAll(Properties p, String pattern, String replacement) {
Properties result = new Properties();
- for (Iterator<Map.Entry<Object, Object>> i = p.entrySet().iterator(); i.hasNext();) {
- Map.Entry<Object, Object> entry = i.next();
+ for (Iterator<Map.Entry<Object,Object>> i = p.entrySet().iterator(); i.hasNext();) {
+ Map.Entry<Object,Object> entry = i.next();
String key = (String) entry.getKey();
String value = (String) entry.getValue();
value = value.replaceAll(pattern, replacement);
@@ -850,17 +855,17 @@
* @return the clauses
* @throws IOException
*/
- public static String printClauses(Map<?, ? extends Map<?, ?>> exports) throws IOException {
+ public static String printClauses(Map< ? , ? extends Map< ? , ? >> exports) throws IOException {
return printClauses(exports, false);
}
- public static String printClauses(Map<?, ? extends Map<?, ?>> exports,
- boolean checkMultipleVersions) throws IOException {
+ public static String printClauses(Map< ? , ? extends Map< ? , ? >> exports, boolean checkMultipleVersions)
+ throws IOException {
StringBuilder sb = new StringBuilder();
String del = "";
- for (Entry<?, ? extends Map<?, ?>> entry : exports.entrySet()) {
+ for (Entry< ? , ? extends Map< ? , ? >> entry : exports.entrySet()) {
String name = entry.getKey().toString();
- Map<?, ?> clause = entry.getValue();
+ Map< ? , ? > clause = entry.getValue();
// We allow names to be duplicated in the input
// by ending them with '~'. This is necessary to use
@@ -876,13 +881,13 @@
return sb.toString();
}
- public static void printClause(Map<?, ?> map, StringBuilder sb) throws IOException {
+ public static void printClause(Map< ? , ? > map, StringBuilder sb) throws IOException {
- for (Entry<?, ?> entry : map.entrySet()) {
+ for (Entry< ? , ? > entry : map.entrySet()) {
Object key = entry.getKey();
// Skip directives we do not recognize
- if (key.equals(NO_IMPORT_DIRECTIVE) || key.equals(PROVIDE_DIRECTIVE)
- || key.equals(SPLIT_PACKAGE_DIRECTIVE) || key.equals(FROM_DIRECTIVE))
+ if (key.equals(NO_IMPORT_DIRECTIVE) || key.equals(PROVIDE_DIRECTIVE) || key.equals(SPLIT_PACKAGE_DIRECTIVE)
+ || key.equals(FROM_DIRECTIVE))
continue;
String value = ((String) entry.getValue()).trim();
@@ -901,8 +906,8 @@
* @throws IOException
*/
public static boolean quote(Appendable sb, String value) throws IOException {
- boolean clean = (value.length() >= 2 && value.charAt(0) == '"' && value.charAt(value
- .length() - 1) == '"') || Verifier.TOKEN.matcher(value).matches();
+ boolean clean = (value.length() >= 2 && value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"')
+ || Verifier.TOKEN.matcher(value).matches();
if (!clean)
sb.append("\"");
sb.append(value);
@@ -1021,7 +1026,8 @@
sb.append(chars, 0, size);
size = ir.read(chars);
}
- } finally {
+ }
+ finally {
ir.close();
}
return sb.toString();
@@ -1033,15 +1039,15 @@
* @param args
* @return
*/
- public static String join(Collection<?> list, String delimeter) {
+ public static String join(Collection< ? > list, String delimeter) {
return join(delimeter, list);
}
- public static String join(String delimeter, Collection<?>... list) {
+ public static String join(String delimeter, Collection< ? >... list) {
StringBuilder sb = new StringBuilder();
String del = "";
if (list != null) {
- for (Collection<?> l : list) {
+ for (Collection< ? > l : list) {
for (Object item : l) {
sb.append(del);
sb.append(item);
@@ -1065,7 +1071,7 @@
return sb.toString();
}
- public static String join(Collection<?>... list) {
+ public static String join(Collection< ? >... list) {
return join(",", list);
}
@@ -1160,11 +1166,12 @@
super.addURL(url);
}
- public Class<?> loadClass(String name) throws NoClassDefFoundError {
+ public Class< ? > loadClass(String name) throws NoClassDefFoundError {
try {
- Class<?> c = super.loadClass(name);
+ Class< ? > c = super.loadClass(name);
return c;
- } catch (Throwable t) {
+ }
+ catch (Throwable t) {
StringBuilder sb = new StringBuilder();
sb.append(name);
sb.append(" not found, parent: ");
@@ -1189,8 +1196,7 @@
* Check if this is a valid project.
*/
public boolean exists() {
- return base != null && base.isDirectory() && propertiesFile != null
- && propertiesFile.isFile();
+ return base != null && base.isDirectory() && propertiesFile != null && propertiesFile.isFile();
}
public boolean isOk() {
@@ -1225,8 +1231,7 @@
return true;
if (!missed.isEmpty())
- System.err
- .println("Missed the following patterns in the warnings or errors: " + missed);
+ System.err.println("Missed the following patterns in the warnings or errors: " + missed);
report(System.err);
return false;
@@ -1259,9 +1264,8 @@
* Answer if the name is a missing plugin's command name. If a bnd file
* contains the command name of a plugin, and that plugin is not available,
* then an error is reported during manifest calculation. This allows the
- * plugin to fail to load when it is not needed.
- *
- * We first get the plugins to ensure it is properly initialized.
+ * plugin to fail to load when it is not needed. We first get the plugins to
+ * ensure it is properly initialized.
*
* @param name
* @return
@@ -1282,7 +1286,6 @@
* @param prefix
* @param suffix
* @return
- *
*/
public static String appendPath(String... parts) {
StringBuilder sb = new StringBuilder();
@@ -1331,8 +1334,7 @@
map.put(attr.substring(0, n), macro.process(attr.substring(n + 1)));
} else
throw new IllegalArgumentException(formatArrays(
- "Invalid attribute on package-info.java in %s , %s. Must be <key>=<name> ",
- clazz, attr));
+ "Invalid attribute on package-info.java in %s , %s. Must be <key>=<name> ", clazz, attr));
}
return map;
}
@@ -1385,7 +1387,7 @@
return join(result);
}
- public synchronized Class<?> getClass(String type, File jar) throws Exception {
+ public synchronized Class< ? > getClass(String type, File jar) throws Exception {
CL cl = getLoader();
cl.add(jar.toURI().toURL());
return cl.loadClass(type);
@@ -1402,9 +1404,8 @@
tm = tm.toUpperCase();
TimeUnit unit = TimeUnit.MILLISECONDS;
Matcher m = Pattern
- .compile(
- "\\s*(\\d+)\\s*(NANOSECONDS|MICROSECONDS|MILLISECONDS|SECONDS|MINUTES|HOURS|DAYS)?")
- .matcher(tm);
+ .compile("\\s*(\\d+)\\s*(NANOSECONDS|MICROSECONDS|MILLISECONDS|SECONDS|MINUTES|HOURS|DAYS)?").matcher(
+ tm);
if (m.matches()) {
long duration = Long.parseLong(tm);
String u = m.group(2);
@@ -1427,9 +1428,9 @@
if (args.length > 1) {
try {
numchars = Integer.parseInt(args[1]);
- } catch (NumberFormatException e) {
- throw new IllegalArgumentException(
- "Invalid character count parameter in ${random} macro.");
+ }
+ catch (NumberFormatException e) {
+ throw new IllegalArgumentException("Invalid character count parameter in ${random} macro.");
}
}
@@ -1439,8 +1440,7 @@
}
char[] letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
- char[] alphanums = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
- .toCharArray();
+ char[] alphanums = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toCharArray();
char[] array = new char[numchars];
for (int i = 0; i < numchars; i++) {
@@ -1458,9 +1458,8 @@
/**
* Set the current command thread. This must be balanced with the
* {@link #end(Processor)} method. The method returns the previous command
- * owner or null.
- *
- * The command owner will receive all warnings and error reports.
+ * owner or null. The command owner will receive all warnings and error
+ * reports.
*/
protected Processor beginHandleErrors(String message) {
@@ -1510,19 +1509,23 @@
/**
* Overrides for the Domain class
*/
- @Override public String get(String key) {
+ @Override
+ public String get(String key) {
return getProperty(key);
}
- @Override public String get(String key, String deflt) {
+ @Override
+ public String get(String key, String deflt) {
return getProperty(key, deflt);
}
- @Override public void set(String key, String value) {
+ @Override
+ public void set(String key, String value) {
getProperties().setProperty(key, value);
}
- @Override public Iterator<String> iterator() {
+ @Override
+ public Iterator<String> iterator() {
Set<String> keys = keySet();
final Iterator<String> it = keys.iterator();
@@ -1565,7 +1568,8 @@
StringBuilder sb = new StringBuilder();
report(sb);
return sb.toString();
- } catch (Exception e) {
+ }
+ catch (Exception e) {
throw new RuntimeException(e);
}
}
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/Resource.java b/bundleplugin/src/main/java/aQute/lib/osgi/Resource.java
index f7df287..6605eef 100755
--- a/bundleplugin/src/main/java/aQute/lib/osgi/Resource.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/Resource.java
@@ -3,10 +3,15 @@
import java.io.*;
public interface Resource {
- InputStream openInputStream() throws Exception ;
+ InputStream openInputStream() throws Exception;
+
void write(OutputStream out) throws Exception;
+
long lastModified();
+
void setExtra(String extra);
+
String getExtra();
+
long size() throws Exception;
}
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/TagResource.java b/bundleplugin/src/main/java/aQute/lib/osgi/TagResource.java
index 0318427..e138175 100644
--- a/bundleplugin/src/main/java/aQute/lib/osgi/TagResource.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/TagResource.java
@@ -11,14 +11,14 @@
this.tag = tag;
}
-
public void write(OutputStream out) throws UnsupportedEncodingException {
OutputStreamWriter ow = new OutputStreamWriter(out, "UTF-8");
PrintWriter pw = new PrintWriter(ow);
pw.println("<?xml version='1.1'?>");
try {
tag.print(0, pw);
- } finally {
+ }
+ finally {
pw.flush();
}
}
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/URLResource.java b/bundleplugin/src/main/java/aQute/lib/osgi/URLResource.java
index 6e96f23..7c4772f 100755
--- a/bundleplugin/src/main/java/aQute/lib/osgi/URLResource.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/URLResource.java
@@ -45,7 +45,7 @@
try {
if (url.getProtocol().equals("file:")) {
File file = new File(url.getPath());
- if ( file.isFile())
+ if (file.isFile())
return size = file.length();
} else {
URLConnection con = url.openConnection();
@@ -59,7 +59,8 @@
}
}
}
- } catch (Exception e) {
+ }
+ catch (Exception e) {
// Forget this exception, we do it the hard way
}
InputStream in = openInputStream();
@@ -67,11 +68,12 @@
try {
din = new DataInputStream(in);
long result = din.skipBytes(Integer.MAX_VALUE);
- while( in.read() >= 0) {
+ while (in.read() >= 0) {
result += din.skipBytes(Integer.MAX_VALUE);
}
size = result;
- } finally {
+ }
+ finally {
if (din != null) {
din.close();
}
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/Verifier.java b/bundleplugin/src/main/java/aQute/lib/osgi/Verifier.java
index 89bd7f0..27026ae 100755
--- a/bundleplugin/src/main/java/aQute/lib/osgi/Verifier.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/Verifier.java
@@ -23,14 +23,11 @@
private boolean r3;
private boolean usesRequire;
- final static Pattern EENAME = Pattern.compile("CDC-1\\.0/Foundation-1\\.0"
- + "|CDC-1\\.1/Foundation-1\\.1"
- + "|OSGi/Minimum-1\\.[1-9]" + "|JRE-1\\.1"
- + "|J2SE-1\\.2" + "|J2SE-1\\.3" + "|J2SE-1\\.4"
- + "|J2SE-1\\.5" + "|JavaSE-1\\.6" + "|JavaSE-1\\.7"
+ final static Pattern EENAME = Pattern.compile("CDC-1\\.0/Foundation-1\\.0" + "|CDC-1\\.1/Foundation-1\\.1"
+ + "|OSGi/Minimum-1\\.[1-9]" + "|JRE-1\\.1" + "|J2SE-1\\.2" + "|J2SE-1\\.3"
+ + "|J2SE-1\\.4" + "|J2SE-1\\.5" + "|JavaSE-1\\.6" + "|JavaSE-1\\.7"
+ "|PersonalJava-1\\.1" + "|PersonalJava-1\\.2"
- + "|CDC-1\\.0/PersonalBasis-1\\.0"
- + "|CDC-1\\.0/PersonalJava-1\\.0");
+ + "|CDC-1\\.0/PersonalBasis-1\\.0" + "|CDC-1\\.0/PersonalJava-1\\.0");
final static int V1_1 = 45;
final static int V1_2 = 46;
@@ -69,37 +66,30 @@
new EE("PersonalJava-1.1", V1_1, V1_1), //
new EE("JavaSE-1.7", V1_7, V1_7), //
new EE("PersonalJava-1.1", V1_1, V1_1), //
- new EE("PersonalJava-1.2", V1_1, V1_1),
- new EE("CDC-1.0/PersonalBasis-1.0", V1_3, V1_1),
- new EE("CDC-1.0/PersonalJava-1.0", V1_3, V1_1),
- new EE("CDC-1.1/PersonalBasis-1.1", V1_3, V1_2),
- new EE("CDC-1.1/PersonalJava-1.1", V1_3, V1_2) };
+ new EE("PersonalJava-1.2", V1_1, V1_1), new EE("CDC-1.0/PersonalBasis-1.0", V1_3, V1_1),
+ new EE("CDC-1.0/PersonalJava-1.0", V1_3, V1_1), new EE("CDC-1.1/PersonalBasis-1.1", V1_3, V1_2),
+ new EE("CDC-1.1/PersonalJava-1.1", V1_3, V1_2)
+ };
- final static Pattern CARDINALITY_PATTERN = Pattern
- .compile("single|multiple");
- final static Pattern RESOLUTION_PATTERN = Pattern
- .compile("optional|mandatory");
+ final static Pattern CARDINALITY_PATTERN = Pattern.compile("single|multiple");
+ final static Pattern RESOLUTION_PATTERN = Pattern.compile("optional|mandatory");
final static Pattern BUNDLEMANIFESTVERSION = Pattern.compile("2");
public final static String SYMBOLICNAME_STRING = "[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)*";
- public final static Pattern SYMBOLICNAME = Pattern
- .compile(SYMBOLICNAME_STRING);
+ public final static Pattern SYMBOLICNAME = Pattern.compile(SYMBOLICNAME_STRING);
public final static String VERSION_STRING = "[0-9]+(\\.[0-9]+(\\.[0-9]+(\\.[0-9A-Za-z_-]+)?)?)?";
public final static Pattern VERSION = Pattern.compile(VERSION_STRING);
final static Pattern FILTEROP = Pattern.compile("=|<=|>=|~=");
public final static Pattern VERSIONRANGE = Pattern.compile("((\\(|\\[)"
- + VERSION_STRING + ","
- + VERSION_STRING
- + "(\\]|\\)))|"
+ + VERSION_STRING + "," + VERSION_STRING + "(\\]|\\)))|"
+ VERSION_STRING);
final static Pattern FILE = Pattern
.compile("/?[^/\"\n\r\u0000]+(/[^/\"\n\r\u0000]+)*");
final static Pattern WILDCARDPACKAGE = Pattern
.compile("((\\p{Alnum}|_)+(\\.(\\p{Alnum}|_)+)*(\\.\\*)?)|\\*");
public final static Pattern ISO639 = Pattern.compile("[A-Z][A-Z]");
- public final static Pattern HEADER_PATTERN = Pattern
- .compile("[A-Za-z0-9][-a-zA-Z0-9_]+");
+ public final static Pattern HEADER_PATTERN = Pattern.compile("[A-Za-z0-9][-a-zA-Z0-9_]+");
public final static Pattern TOKEN = Pattern.compile("[-a-zA-Z0-9_]+");
public final static Pattern NUMBERPATTERN = Pattern.compile("\\d+");
@@ -110,18 +100,18 @@
public final static Pattern URLPATTERN = Pattern.compile(".*");
public final static Pattern ANYPATTERN = Pattern.compile(".*");
public final static Pattern FILTERPATTERN = Pattern.compile(".*");
- public final static Pattern TRUEORFALSEPATTERN = Pattern
- .compile("true|false|TRUE|FALSE");
+ public final static Pattern TRUEORFALSEPATTERN = Pattern.compile("true|false|TRUE|FALSE");
public static final Pattern WILDCARDNAMEPATTERN = Pattern.compile(".*");
public static final Pattern BUNDLE_ACTIVATIONPOLICYPATTERN = Pattern.compile("lazy");
- public final static String EES[] = { "CDC-1.0/Foundation-1.0",
- "CDC-1.1/Foundation-1.1", "OSGi/Minimum-1.0", "OSGi/Minimum-1.1", "OSGi/Minimum-1.2",
- "JRE-1.1", "J2SE-1.2", "J2SE-1.3", "J2SE-1.4", "J2SE-1.5", "JavaSE-1.6", "JavaSE-1.7",
- "PersonalJava-1.1", "PersonalJava-1.2", "CDC-1.0/PersonalBasis-1.0",
- "CDC-1.0/PersonalJava-1.0" };
+ public final static String EES[] = {
+ "CDC-1.0/Foundation-1.0", "CDC-1.1/Foundation-1.1", "OSGi/Minimum-1.0", "OSGi/Minimum-1.1",
+ "OSGi/Minimum-1.2", "JRE-1.1", "J2SE-1.2", "J2SE-1.3", "J2SE-1.4", "J2SE-1.5", "JavaSE-1.6", "JavaSE-1.7",
+ "PersonalJava-1.1", "PersonalJava-1.2", "CDC-1.0/PersonalBasis-1.0", "CDC-1.0/PersonalJava-1.0"
+ };
- public final static String OSNAMES[] = { "AIX", // IBM
+ public final static String OSNAMES[] = {
+ "AIX", // IBM
"DigitalUnix", // Compaq
"Embos", // Segger Embedded Software Solutions
"Epoc32", // SymbianOS Symbian OS
@@ -140,10 +130,11 @@
"VxWorks", // WindRiver Systems
"Windows95", "Win32", "Windows98", "WindowsNT", "WindowsCE", "Windows2000", // Win2000
"Windows2003", // Win2003
- "WindowsXP", "WindowsVista", };
+ "WindowsXP", "WindowsVista",
+ };
public final static String PROCESSORNAMES[] = { //
- //
+ //
"68k", // Motorola 68000
"ARM_LE", // Intel Strong ARM. Deprecated because it does not
// specify the endianness. See the following two rows.
@@ -164,7 +155,8 @@
"V850E", // NEC V850E
"x86", // pentium i386
"i486", // i586 i686 Intel& AMD 32 bit
- "x86-64", };
+ "x86-64",
+ };
final Analyzer analyzer;
private Instructions dynamicImports;
@@ -265,7 +257,8 @@
try {
verifyFilter(value, 0);
return null;
- } catch (Exception e) {
+ }
+ catch (Exception e) {
return "Not a valid filter: " + value + e.getMessage();
}
}
@@ -281,8 +274,7 @@
if (packageRef.isDefaultPackage())
error("The Bundle Activator is not in the bundle and it is in the default package ");
else if (!analyzer.isImported(packageRef)) {
- error("Bundle-Activator not found on the bundle class path nor in imports: "
- + bactivator);
+ error("Bundle-Activator not found on the bundle class path nor in imports: " + bactivator);
}
}
}
@@ -308,8 +300,7 @@
* referred packages.
*/
private void verifyUnresolvedReferences() {
- Set<PackageRef> unresolvedReferences = new TreeSet<PackageRef>(analyzer.getReferred()
- .keySet());
+ Set<PackageRef> unresolvedReferences = new TreeSet<PackageRef>(analyzer.getReferred().keySet());
unresolvedReferences.removeAll(analyzer.getImports().keySet());
unresolvedReferences.removeAll(analyzer.getContained().keySet());
@@ -334,8 +325,8 @@
culprits.add(clazz.getAbsolutePath());
}
- error("Unresolved references to %s by class(es) %s on the Bundle-Classpath: %s",
- unresolvedReferences, culprits, analyzer.getBundleClasspath().keySet());
+ error("Unresolved references to %s by class(es) %s on the Bundle-Classpath: %s", unresolvedReferences,
+ culprits, analyzer.getBundleClasspath().keySet());
}
}
@@ -350,8 +341,8 @@
return dynamicImports.matches(pack.getFQN());
}
- private boolean hasOverlap(Set<?> a, Set<?> b) {
- for (Iterator<?> i = a.iterator(); i.hasNext();) {
+ private boolean hasOverlap(Set< ? > a, Set< ? > b) {
+ for (Iterator< ? > i = a.iterator(); i.hasNext();) {
if (b.contains(i.next()))
return true;
}
@@ -360,15 +351,14 @@
public void verify() throws Exception {
verifyHeaders();
- verifyDirectives("Export-Package",
- "uses:|mandatory:|include:|exclude:|" + IMPORT_DIRECTIVE, PACKAGEPATTERN, "package");
+ verifyDirectives("Export-Package", "uses:|mandatory:|include:|exclude:|" + IMPORT_DIRECTIVE, PACKAGEPATTERN,
+ "package");
verifyDirectives("Import-Package", "resolution:", PACKAGEPATTERN, "package");
verifyDirectives("Require-Bundle", "visibility:|resolution:", SYMBOLICNAME, "bsn");
verifyDirectives("Fragment-Host", "extension:", SYMBOLICNAME, "bsn");
verifyDirectives("Provide-Capability", "effective:|uses:", null, null);
- verifyDirectives("Require-Capability", "effective:|resolution:|filter:", null,null);
- verifyDirectives("Bundle-SymbolicName", "singleton:|fragment-attachment:|mandatory:",
- SYMBOLICNAME,"bsn");
+ verifyDirectives("Require-Capability", "effective:|resolution:|filter:", null, null);
+ verifyDirectives("Bundle-SymbolicName", "singleton:|fragment-attachment:|mandatory:", SYMBOLICNAME, "bsn");
verifyManifestFirst();
verifyActivator();
@@ -397,15 +387,12 @@
}
private void verifyRequirements() {
- Parameters map = parseHeader(manifest.getMainAttributes().getValue(
- Constants.REQUIRE_CAPABILITY));
+ Parameters map = parseHeader(manifest.getMainAttributes().getValue(Constants.REQUIRE_CAPABILITY));
for (String key : map.keySet()) {
Attrs attrs = map.get(key);
verify(attrs, "filter:", FILTERPATTERN, false, "Requirement %s filter not correct", key);
- verify(attrs, "cardinality:", CARDINALITY_PATTERN, false,
- "Requirement %s cardinality not correct", key);
- verify(attrs, "resolution:", RESOLUTION_PATTERN, false,
- "Requirement %s resolution not correct", key);
+ verify(attrs, "cardinality:", CARDINALITY_PATTERN, false, "Requirement %s cardinality not correct", key);
+ verify(attrs, "resolution:", RESOLUTION_PATTERN, false, "Requirement %s resolution not correct", key);
if (key.equals("osgi.extender")) {
// No requirements on extender
@@ -451,20 +438,16 @@
}
private void verifyCapabilities() {
- Parameters map = parseHeader(manifest.getMainAttributes().getValue(
- Constants.PROVIDE_CAPABILITY));
+ Parameters map = parseHeader(manifest.getMainAttributes().getValue(Constants.PROVIDE_CAPABILITY));
for (String key : map.keySet()) {
Attrs attrs = map.get(key);
- verify(attrs, "cardinality:", CARDINALITY_PATTERN, false,
- "Requirement %s cardinality not correct", key);
- verify(attrs, "resolution:", RESOLUTION_PATTERN, false,
- "Requirement %s resolution not correct", key);
+ verify(attrs, "cardinality:", CARDINALITY_PATTERN, false, "Requirement %s cardinality not correct", key);
+ verify(attrs, "resolution:", RESOLUTION_PATTERN, false, "Requirement %s resolution not correct", key);
if (key.equals("osgi.extender")) {
verify(attrs, "osgi.extender", SYMBOLICNAME, true,
"Extender %s must always have the osgi.extender attribute set", key);
- verify(attrs, "version", VERSION, true, "Extender %s must always have a version",
- key);
+ verify(attrs, "version", VERSION, true, "Extender %s must always have a version", key);
} else if (key.equals("osgi.serviceloader")) {
verify(attrs, "register:", PACKAGEPATTERN, false,
"Service Loader extender register: directive not a fully qualified Java name");
@@ -493,8 +476,7 @@
}
}
- private void verify(Attrs attrs, String ad, Pattern pattern, boolean mandatory, String msg,
- String... args) {
+ private void verify(Attrs attrs, String ad, Pattern pattern, boolean mandatory, String msg, String... args) {
String v = attrs.get(ad);
if (v == null) {
if (mandatory)
@@ -519,7 +501,7 @@
private void verifyDirectives(String header, String directives, Pattern namePattern, String type) {
Pattern pattern = Pattern.compile(directives);
Parameters map = parseHeader(manifest.getMainAttributes().getValue(header));
- for (Entry<String, Attrs> entry : map.entrySet()) {
+ for (Entry<String,Attrs> entry : map.entrySet()) {
String pname = removeDuplicateMarker(entry.getKey());
if (namePattern != null) {
@@ -529,7 +511,7 @@
else
warning("Invalid %s name: '%s'", type, pname);
}
-
+
for (String key : entry.getValue().keySet()) {
if (key.endsWith(":")) {
if (!key.startsWith("x-")) {
@@ -537,8 +519,8 @@
if (m.matches())
continue;
- warning("Unknown directive %s in %s, allowed directives are %s, and 'x-*'.",
- key, header, directives.replace('|', ','));
+ warning("Unknown directive %s in %s, allowed directives are %s, and 'x-*'.", key, header,
+ directives.replace('|', ','));
}
}
}
@@ -578,7 +560,7 @@
else if (map.size() > 1)
warning("Bundle-ActivationPolicy has too many arguments %s", policy);
else {
- Map<String, String> s = map.get("lazy");
+ Map<String,String> s = map.get("lazy");
if (s == null)
warning("Bundle-ActivationPolicy set but is not set to lazy: %s", policy);
else
@@ -635,10 +617,9 @@
if (!verify(name, WILDCARDPACKAGE))
error("DynamicImport-Package header contains an invalid package name: " + name);
- Map<String, String> sub = map.get(name);
+ Map<String,String> sub = map.get(name);
if (r3 && sub.size() != 0) {
- error("DynamicPackage-Import has attributes on import: "
- + name
+ error("DynamicPackage-Import has attributes on import: " + name
+ ". This is however, an <=R3 bundle and attributes on this header were introduced in R4. ");
}
}
@@ -706,8 +687,7 @@
index++;
if (expr.charAt(index) != '(')
- throw new IllegalArgumentException("Filter mismatch: expected ( at position "
- + index + " : " + expr);
+ throw new IllegalArgumentException("Filter mismatch: expected ( at position " + index + " : " + expr);
index++; // skip (
@@ -715,50 +695,50 @@
index++;
switch (expr.charAt(index)) {
- case '!':
- index++; // skip !
- while (Character.isWhitespace(expr.charAt(index)))
- index++;
+ case '!' :
+ index++; // skip !
+ while (Character.isWhitespace(expr.charAt(index)))
+ index++;
- if (expr.charAt(index) != '(')
- throw new IllegalArgumentException(
- "Filter mismatch: ! (not) must have one sub expression " + index
- + " : " + expr);
- while (Character.isWhitespace(expr.charAt(index)))
- index++;
+ if (expr.charAt(index) != '(')
+ throw new IllegalArgumentException("Filter mismatch: ! (not) must have one sub expression "
+ + index + " : " + expr);
+ while (Character.isWhitespace(expr.charAt(index)))
+ index++;
- index = verifyFilter(expr, index);
- while (Character.isWhitespace(expr.charAt(index)))
- index++;
- if (expr.charAt(index) != ')')
- throw new IllegalArgumentException("Filter mismatch: expected ) at position "
- + index + " : " + expr);
- return index + 1;
-
- case '&':
- case '|':
- index++; // skip operator
- while (Character.isWhitespace(expr.charAt(index)))
- index++;
- while (expr.charAt(index) == '(') {
index = verifyFilter(expr, index);
while (Character.isWhitespace(expr.charAt(index)))
index++;
- }
+ if (expr.charAt(index) != ')')
+ throw new IllegalArgumentException("Filter mismatch: expected ) at position " + index + " : "
+ + expr);
+ return index + 1;
- if (expr.charAt(index) != ')')
- throw new IllegalArgumentException("Filter mismatch: expected ) at position "
- + index + " : " + expr);
- return index + 1; // skip )
+ case '&' :
+ case '|' :
+ index++; // skip operator
+ while (Character.isWhitespace(expr.charAt(index)))
+ index++;
+ while (expr.charAt(index) == '(') {
+ index = verifyFilter(expr, index);
+ while (Character.isWhitespace(expr.charAt(index)))
+ index++;
+ }
- default:
- index = verifyFilterOperation(expr, index);
- if (expr.charAt(index) != ')')
- throw new IllegalArgumentException("Filter mismatch: expected ) at position "
- + index + " : " + expr);
- return index + 1;
+ if (expr.charAt(index) != ')')
+ throw new IllegalArgumentException("Filter mismatch: expected ) at position " + index + " : "
+ + expr);
+ return index + 1; // skip )
+
+ default :
+ index = verifyFilterOperation(expr, index);
+ if (expr.charAt(index) != ')')
+ throw new IllegalArgumentException("Filter mismatch: expected ) at position " + index + " : "
+ + expr);
+ return index + 1;
}
- } catch (IndexOutOfBoundsException e) {
+ }
+ catch (IndexOutOfBoundsException e) {
throw new IllegalArgumentException("Filter mismatch: early EOF from " + index);
}
}
@@ -777,19 +757,17 @@
}
String operator = sb.toString();
if (!verify(operator, FILTEROP))
- throw new IllegalArgumentException("Filter error, illegal operator " + operator
- + " at index " + index);
+ throw new IllegalArgumentException("Filter error, illegal operator " + operator + " at index " + index);
sb = new StringBuilder();
while (")".indexOf(expr.charAt(index)) < 0) {
switch (expr.charAt(index)) {
- case '\\':
- if ("\\)(*".indexOf(expr.charAt(index + 1)) >= 0)
- index++;
- else
- throw new IllegalArgumentException(
- "Filter error, illegal use of backslash at index " + index
- + ". Backslash may only be used before * or () or \\");
+ case '\\' :
+ if ("\\)(*".indexOf(expr.charAt(index + 1)) >= 0)
+ index++;
+ else
+ throw new IllegalArgumentException("Filter error, illegal use of backslash at index " + index
+ + ". Backslash may only be used before * or () or \\");
}
sb.append(expr.charAt(index++));
}
@@ -804,8 +782,7 @@
QuotedTokenizer st = new QuotedTokenizer(value.trim(), ",");
for (Iterator<String> i = st.getTokenSet().iterator(); i.hasNext();) {
if (!verify(i.next(), regex)) {
- String msg = "Invalid value for " + name + ", " + value + " does not match "
- + regex.pattern();
+ String msg = "Invalid value for " + name + ", " + value + " does not match " + regex.pattern();
if (error)
error(msg);
else
@@ -827,8 +804,7 @@
Parameters map = parseHeader(value);
for (String header : map.keySet()) {
if (!regex.matcher(header).matches()) {
- String msg = "Invalid value for " + name + ", " + value + " does not match "
- + regex.pattern();
+ String msg = "Invalid value for " + name + ", " + value + " does not match " + regex.pattern();
if (error)
error(msg);
else
@@ -926,8 +902,7 @@
IO.copy(in, digester);
digester.digest();
if (!expected.equals(digester.digest())) {
- error("Checksum mismatch %s, expected %s, got %s", path, expected,
- digester.digest());
+ error("Checksum mismatch %s, expected %s, got %s", path, expected, digester.digest());
}
}
}
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/WriteResource.java b/bundleplugin/src/main/java/aQute/lib/osgi/WriteResource.java
index 2acbe95..5cc5229 100644
--- a/bundleplugin/src/main/java/aQute/lib/osgi/WriteResource.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/WriteResource.java
@@ -3,34 +3,37 @@
import java.io.*;
public abstract class WriteResource implements Resource {
- String extra;
- volatile long size = -1;
-
+ String extra;
+ volatile long size = -1;
+
public InputStream openInputStream() throws Exception {
- PipedInputStream pin = new PipedInputStream();
- final PipedOutputStream pout = new PipedOutputStream(pin);
- Thread t = new Thread() {
- public void run() {
- try {
- write(pout);
- pout.flush();
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- try {
- pout.close();
- } catch (IOException e) {
- // Ignore
- }
- }
- }
- };
- t.start();
- return pin;
+ PipedInputStream pin = new PipedInputStream();
+ final PipedOutputStream pout = new PipedOutputStream(pin);
+ Thread t = new Thread() {
+ public void run() {
+ try {
+ write(pout);
+ pout.flush();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ finally {
+ try {
+ pout.close();
+ }
+ catch (IOException e) {
+ // Ignore
+ }
+ }
+ }
+ };
+ t.start();
+ return pin;
}
public abstract void write(OutputStream out) throws IOException, Exception;
-
+
public abstract long lastModified();
public String getExtra() {
@@ -40,25 +43,28 @@
public void setExtra(String extra) {
this.extra = extra;
}
-
- static class CountingOutputStream extends OutputStream {
- long size;
- @Override public void write(int var0) throws IOException {
+ static class CountingOutputStream extends OutputStream {
+ long size;
+
+ @Override
+ public void write(int var0) throws IOException {
size++;
}
-
- @Override public void write(byte[] buffer) throws IOException {
- size+=buffer.length;
+
+ @Override
+ public void write(byte[] buffer) throws IOException {
+ size += buffer.length;
}
-
- @Override public void write(byte [] buffer, int start, int length) throws IOException {
- size+=length;
+
+ @Override
+ public void write(byte[] buffer, int start, int length) throws IOException {
+ size += length;
}
}
-
+
public long size() throws IOException, Exception {
- if ( size == -1 ) {
+ if (size == -1) {
CountingOutputStream cout = new CountingOutputStream();
write(cout);
size = cout.size;
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/ZipResource.java b/bundleplugin/src/main/java/aQute/lib/osgi/ZipResource.java
index 126faba..f5e2095 100755
--- a/bundleplugin/src/main/java/aQute/lib/osgi/ZipResource.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/ZipResource.java
@@ -6,83 +6,78 @@
import java.util.zip.*;
public class ZipResource implements Resource {
- ZipFile zip;
- ZipEntry entry;
- long lastModified;
- String extra;
+ ZipFile zip;
+ ZipEntry entry;
+ long lastModified;
+ String extra;
- ZipResource(ZipFile zip, ZipEntry entry, long lastModified) throws UnsupportedEncodingException {
- this.zip = zip;
- this.entry = entry;
- this.lastModified = lastModified;
- byte[] data = entry.getExtra();
- if (data != null)
- this.extra = new String(data, "UTF-8");
- }
+ ZipResource(ZipFile zip, ZipEntry entry, long lastModified) throws UnsupportedEncodingException {
+ this.zip = zip;
+ this.entry = entry;
+ this.lastModified = lastModified;
+ byte[] data = entry.getExtra();
+ if (data != null)
+ this.extra = new String(data, "UTF-8");
+ }
- public InputStream openInputStream() throws IOException {
- return zip.getInputStream(entry);
- }
+ public InputStream openInputStream() throws IOException {
+ return zip.getInputStream(entry);
+ }
- public String toString() {
- return ":" + zip.getName() + "(" + entry.getName() + "):";
- }
+ public String toString() {
+ return ":" + zip.getName() + "(" + entry.getName() + "):";
+ }
- public static ZipFile build(Jar jar, File file) throws ZipException,
- IOException {
- return build(jar, file, null);
- }
+ public static ZipFile build(Jar jar, File file) throws ZipException, IOException {
+ return build(jar, file, null);
+ }
- public static ZipFile build(Jar jar, File file, Pattern pattern)
- throws ZipException, IOException {
+ public static ZipFile build(Jar jar, File file, Pattern pattern) throws ZipException, IOException {
- try {
- ZipFile zip = new ZipFile(file);
- nextEntry: for (Enumeration<? extends ZipEntry> e = zip.entries(); e
- .hasMoreElements();) {
- ZipEntry entry = e.nextElement();
- if (pattern != null) {
- Matcher m = pattern.matcher(entry.getName());
- if (!m.matches())
- continue nextEntry;
- }
- if (!entry.isDirectory()) {
- long time = entry.getTime();
- if (time <= 0)
- time = file.lastModified();
- jar.putResource(entry.getName(), new ZipResource(zip,
- entry, time), true);
- }
- }
- return zip;
- } catch (ZipException ze) {
- throw new ZipException("The JAR/ZIP file ("
- + file.getAbsolutePath() + ") seems corrupted, error: "
- + ze.getMessage());
- } catch (FileNotFoundException e) {
- throw new IllegalArgumentException("Problem opening JAR: "
- + file.getAbsolutePath());
- }
- }
+ try {
+ ZipFile zip = new ZipFile(file);
+ nextEntry: for (Enumeration< ? extends ZipEntry> e = zip.entries(); e.hasMoreElements();) {
+ ZipEntry entry = e.nextElement();
+ if (pattern != null) {
+ Matcher m = pattern.matcher(entry.getName());
+ if (!m.matches())
+ continue nextEntry;
+ }
+ if (!entry.isDirectory()) {
+ long time = entry.getTime();
+ if (time <= 0)
+ time = file.lastModified();
+ jar.putResource(entry.getName(), new ZipResource(zip, entry, time), true);
+ }
+ }
+ return zip;
+ }
+ catch (ZipException ze) {
+ throw new ZipException("The JAR/ZIP file (" + file.getAbsolutePath() + ") seems corrupted, error: "
+ + ze.getMessage());
+ }
+ catch (FileNotFoundException e) {
+ throw new IllegalArgumentException("Problem opening JAR: " + file.getAbsolutePath());
+ }
+ }
- public void write(OutputStream out) throws Exception {
- FileResource.copy(this, out);
- }
+ public void write(OutputStream out) throws Exception {
+ FileResource.copy(this, out);
+ }
- public long lastModified() {
- return lastModified;
- }
+ public long lastModified() {
+ return lastModified;
+ }
- public String getExtra() {
- return extra;
- }
+ public String getExtra() {
+ return extra;
+ }
- public void setExtra(String extra) {
- this.extra = extra;
- }
+ public void setExtra(String extra) {
+ this.extra = extra;
+ }
-
- public long size() {
- return entry.getSize();
- }
+ public long size() {
+ return entry.getSize();
+ }
}
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/eclipse/EclipseClasspath.java b/bundleplugin/src/main/java/aQute/lib/osgi/eclipse/EclipseClasspath.java
index 6e01ddc..2244fd2 100755
--- a/bundleplugin/src/main/java/aQute/lib/osgi/eclipse/EclipseClasspath.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/eclipse/EclipseClasspath.java
@@ -19,230 +19,220 @@
* @version $Revision$
*/
public class EclipseClasspath {
- static DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory
- .newInstance();
- DocumentBuilder db;
- File project;
- File workspace;
- Set<File> sources = new LinkedHashSet<File>();
- Set<File> allSources = new LinkedHashSet<File>();
-
- Set<File> classpath = new LinkedHashSet<File>();
- List<File> dependents = new ArrayList<File>();
- File output;
- boolean recurse = true;
- Set<File> exports = new LinkedHashSet<File>();
- Map<String, String> properties = new HashMap<String, String>();
- Reporter reporter;
- int options;
- Set<File> bootclasspath = new LinkedHashSet<File>();
+ static DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db;
+ File project;
+ File workspace;
+ Set<File> sources = new LinkedHashSet<File>();
+ Set<File> allSources = new LinkedHashSet<File>();
- public final static int DO_VARIABLES = 1;
+ Set<File> classpath = new LinkedHashSet<File>();
+ List<File> dependents = new ArrayList<File>();
+ File output;
+ boolean recurse = true;
+ Set<File> exports = new LinkedHashSet<File>();
+ Map<String,String> properties = new HashMap<String,String>();
+ Reporter reporter;
+ int options;
+ Set<File> bootclasspath = new LinkedHashSet<File>();
- /**
- * Parse an Eclipse project structure to discover the classpath.
- *
- * @param workspace
- * Points to workspace
- * @param project
- * Points to project
- * @throws ParserConfigurationException
- * @throws SAXException
- * @throws IOException
- */
+ public final static int DO_VARIABLES = 1;
- public EclipseClasspath(Reporter reporter, File workspace, File project,
- int options) throws Exception {
- this.project = project.getCanonicalFile();
- this.workspace = workspace.getCanonicalFile();
- this.reporter = reporter;
- db = documentBuilderFactory.newDocumentBuilder();
- parse(this.project, true);
- db = null;
- }
+ /**
+ * Parse an Eclipse project structure to discover the classpath.
+ *
+ * @param workspace
+ * Points to workspace
+ * @param project
+ * Points to project
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws IOException
+ */
- public EclipseClasspath(Reporter reporter, File workspace, File project)
- throws Exception {
- this(reporter, workspace, project, 0);
- }
+ public EclipseClasspath(Reporter reporter, File workspace, File project, int options) throws Exception {
+ this.project = project.getCanonicalFile();
+ this.workspace = workspace.getCanonicalFile();
+ this.reporter = reporter;
+ db = documentBuilderFactory.newDocumentBuilder();
+ parse(this.project, true);
+ db = null;
+ }
- /**
- * Recursive routine to parse the files. If a sub project is detected, it is
- * parsed before the parsing continues. This should give the right order.
- *
- * @param project
- * Project directory
- * @param top
- * If this is the top project
- * @throws ParserConfigurationException
- * @throws SAXException
- * @throws IOException
- */
- void parse(File project, boolean top) throws ParserConfigurationException,
- SAXException, IOException {
- File file = new File(project, ".classpath");
- if (!file.exists())
- throw new FileNotFoundException(".classpath file not found: "
- + file.getAbsolutePath());
+ public EclipseClasspath(Reporter reporter, File workspace, File project) throws Exception {
+ this(reporter, workspace, project, 0);
+ }
- Document doc = db.parse(file);
- NodeList nodelist = doc.getDocumentElement().getElementsByTagName(
- "classpathentry");
+ /**
+ * Recursive routine to parse the files. If a sub project is detected, it is
+ * parsed before the parsing continues. This should give the right order.
+ *
+ * @param project
+ * Project directory
+ * @param top
+ * If this is the top project
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws IOException
+ */
+ void parse(File project, boolean top) throws ParserConfigurationException, SAXException, IOException {
+ File file = new File(project, ".classpath");
+ if (!file.exists())
+ throw new FileNotFoundException(".classpath file not found: " + file.getAbsolutePath());
- if (nodelist == null)
- throw new IllegalArgumentException(
- "Can not find classpathentry in classpath file");
+ Document doc = db.parse(file);
+ NodeList nodelist = doc.getDocumentElement().getElementsByTagName("classpathentry");
- for (int i = 0; i < nodelist.getLength(); i++) {
- Node node = nodelist.item(i);
- NamedNodeMap attrs = node.getAttributes();
- String kind = get(attrs, "kind");
- if ("src".equals(kind)) {
- String path = get(attrs, "path");
- // TODO boolean exported = "true".equalsIgnoreCase(get(attrs,
- // "exported"));
- if (path.startsWith("/")) {
- // We have another project
- File subProject = getFile(workspace, project, path);
- if (recurse)
- parse(subProject, false);
- dependents.add(subProject.getCanonicalFile());
- } else {
- File src = getFile(workspace, project, path);
- allSources.add(src);
- if (top) {
- // We only want the sources for our own project
- // or we'll compile all at once. Not a good idea
- // because project settings can differ.
- sources.add(src);
- }
- }
- } else if ("lib".equals(kind)) {
- String path = get(attrs, "path");
- boolean exported = "true".equalsIgnoreCase(get(attrs,
- "exported"));
- if (top || exported) {
- File jar = getFile(workspace, project, path);
- if (jar.getName().startsWith("ee."))
- bootclasspath.add(jar);
- else
- classpath.add(jar);
- if (exported)
- exports.add(jar);
- }
- } else if ("output".equals(kind)) {
- String path = get(attrs, "path");
- path = path.replace('/', File.separatorChar);
- output = getFile(workspace, project, path);
- classpath.add(output);
- exports.add(output);
- } else if ("var".equals(kind)) {
- boolean exported = "true".equalsIgnoreCase(get(attrs,
- "exported"));
- File lib = replaceVar(get(attrs, "path"));
- File slib = replaceVar(get(attrs, "sourcepath"));
- if (lib != null) {
- classpath.add(lib);
- if (exported)
- exports.add(lib);
- }
- if (slib != null)
- sources.add(slib);
- } else if ("con".equals(kind)) {
- // Should do something useful ...
- }
- }
- }
+ if (nodelist == null)
+ throw new IllegalArgumentException("Can not find classpathentry in classpath file");
- private File getFile(File abs, File relative, String opath) {
- String path = opath.replace('/', File.separatorChar);
- File result = new File(path);
- if (result.isAbsolute() && result.isFile()) {
- return result;
- }
- if (path.startsWith(File.separator)) {
- result = abs;
- path = path.substring(1);
- } else
- result = relative;
+ for (int i = 0; i < nodelist.getLength(); i++) {
+ Node node = nodelist.item(i);
+ NamedNodeMap attrs = node.getAttributes();
+ String kind = get(attrs, "kind");
+ if ("src".equals(kind)) {
+ String path = get(attrs, "path");
+ // TODO boolean exported = "true".equalsIgnoreCase(get(attrs,
+ // "exported"));
+ if (path.startsWith("/")) {
+ // We have another project
+ File subProject = getFile(workspace, project, path);
+ if (recurse)
+ parse(subProject, false);
+ dependents.add(subProject.getCanonicalFile());
+ } else {
+ File src = getFile(workspace, project, path);
+ allSources.add(src);
+ if (top) {
+ // We only want the sources for our own project
+ // or we'll compile all at once. Not a good idea
+ // because project settings can differ.
+ sources.add(src);
+ }
+ }
+ } else if ("lib".equals(kind)) {
+ String path = get(attrs, "path");
+ boolean exported = "true".equalsIgnoreCase(get(attrs, "exported"));
+ if (top || exported) {
+ File jar = getFile(workspace, project, path);
+ if (jar.getName().startsWith("ee."))
+ bootclasspath.add(jar);
+ else
+ classpath.add(jar);
+ if (exported)
+ exports.add(jar);
+ }
+ } else if ("output".equals(kind)) {
+ String path = get(attrs, "path");
+ path = path.replace('/', File.separatorChar);
+ output = getFile(workspace, project, path);
+ classpath.add(output);
+ exports.add(output);
+ } else if ("var".equals(kind)) {
+ boolean exported = "true".equalsIgnoreCase(get(attrs, "exported"));
+ File lib = replaceVar(get(attrs, "path"));
+ File slib = replaceVar(get(attrs, "sourcepath"));
+ if (lib != null) {
+ classpath.add(lib);
+ if (exported)
+ exports.add(lib);
+ }
+ if (slib != null)
+ sources.add(slib);
+ } else if ("con".equals(kind)) {
+ // Should do something useful ...
+ }
+ }
+ }
- StringTokenizer st = new StringTokenizer(path, File.separator);
- while (st.hasMoreTokens()) {
- String token = st.nextToken();
- result = new File(result, token);
- }
+ private File getFile(File abs, File relative, String opath) {
+ String path = opath.replace('/', File.separatorChar);
+ File result = new File(path);
+ if (result.isAbsolute() && result.isFile()) {
+ return result;
+ }
+ if (path.startsWith(File.separator)) {
+ result = abs;
+ path = path.substring(1);
+ } else
+ result = relative;
- if (!result.exists())
- System.err.println("File not found: project=" + project
- + " workspace=" + workspace + " path=" + opath + " file="
- + result);
- return result;
- }
+ StringTokenizer st = new StringTokenizer(path, File.separator);
+ while (st.hasMoreTokens()) {
+ String token = st.nextToken();
+ result = new File(result, token);
+ }
- static Pattern PATH = Pattern.compile("([A-Z_]+)/(.*)");
+ if (!result.exists())
+ System.err.println("File not found: project=" + project + " workspace=" + workspace + " path=" + opath
+ + " file=" + result);
+ return result;
+ }
- private File replaceVar(String path) {
- if ((options & DO_VARIABLES) == 0)
- return null;
+ static Pattern PATH = Pattern.compile("([A-Z_]+)/(.*)");
- Matcher m = PATH.matcher(path);
- if (m.matches()) {
- String var = m.group(1);
- String remainder = m.group(2);
- String base = properties.get(var);
- if (base != null) {
- File b = new File(base);
- File f = new File(b, remainder.replace('/', File.separatorChar));
- return f;
- } else
- reporter.error("Can't find replacement variable for: " + path);
- } else
- reporter.error("Cant split variable path: " + path);
- return null;
- }
+ private File replaceVar(String path) {
+ if ((options & DO_VARIABLES) == 0)
+ return null;
- private String get(NamedNodeMap map, String name) {
- Node node = map.getNamedItem(name);
- if (node == null)
- return null;
+ Matcher m = PATH.matcher(path);
+ if (m.matches()) {
+ String var = m.group(1);
+ String remainder = m.group(2);
+ String base = properties.get(var);
+ if (base != null) {
+ File b = new File(base);
+ File f = new File(b, remainder.replace('/', File.separatorChar));
+ return f;
+ } else
+ reporter.error("Can't find replacement variable for: " + path);
+ } else
+ reporter.error("Cant split variable path: " + path);
+ return null;
+ }
- return node.getNodeValue();
- }
+ private String get(NamedNodeMap map, String name) {
+ Node node = map.getNamedItem(name);
+ if (node == null)
+ return null;
- public Set<File> getClasspath() {
- return classpath;
- }
+ return node.getNodeValue();
+ }
- public Set<File> getSourcepath() {
- return sources;
- }
+ public Set<File> getClasspath() {
+ return classpath;
+ }
- public File getOutput() {
- return output;
- }
+ public Set<File> getSourcepath() {
+ return sources;
+ }
- public List<File> getDependents() {
- return dependents;
- }
+ public File getOutput() {
+ return output;
+ }
- public void setRecurse(boolean recurse) {
- this.recurse = recurse;
- }
+ public List<File> getDependents() {
+ return dependents;
+ }
- public Set<File> getExports() {
- return exports;
- }
+ public void setRecurse(boolean recurse) {
+ this.recurse = recurse;
+ }
- public void setProperties(Map<String, String> map) {
- this.properties = map;
- }
+ public Set<File> getExports() {
+ return exports;
+ }
- public Set<File> getBootclasspath() {
- return bootclasspath;
- }
+ public void setProperties(Map<String,String> map) {
+ this.properties = map;
+ }
- public Set<File> getAllSources() {
- return allSources;
- }
+ public Set<File> getBootclasspath() {
+ return bootclasspath;
+ }
+
+ public Set<File> getAllSources() {
+ return allSources;
+ }
}