[Git][java-team/sezpoz][master] 14 commits: Wrap and sort
Emmanuel Bourg
gitlab at salsa.debian.org
Wed Jun 6 19:16:25 BST 2018
Emmanuel Bourg pushed to branch master at Debian Java Maintainers / sezpoz
Commits:
425cb94d by Emmanuel Bourg at 2018-03-26T02:11:25+02:00
Wrap and sort
- - - - -
5048f062 by Emmanuel Bourg at 2018-03-26T02:11:42+02:00
Standards-Version updated to 4.1.3
- - - - -
4b39554c by Emmanuel Bourg at 2018-03-26T02:11:45+02:00
Switch to debhelper level 11
- - - - -
7a15a0d3 by Emmanuel Bourg at 2018-03-26T02:11:56+02:00
Use a secure Vcs-Git URL
- - - - -
8b6d17c6 by Emmanuel Bourg at 2018-03-26T02:13:06+02:00
Build with the DH sequencer instead of CDBS
- - - - -
b98188b9 by Emmanuel Bourg at 2018-03-26T02:15:15+02:00
New upstream version 1.11
- - - - -
48620b78 by Emmanuel Bourg at 2018-03-26T02:15:17+02:00
Update upstream source from tag 'upstream/1.11'
Update to upstream version '1.11'
with Debian dir 7d40558cc14c1661625896c83ea590011cfa7a0a
- - - - -
8e510b11 by Emmanuel Bourg at 2018-03-26T02:17:37+02:00
New upstream version 1.12
- - - - -
6aceff0e by Emmanuel Bourg at 2018-03-26T02:17:39+02:00
Update upstream source from tag 'upstream/1.12'
Update to upstream version '1.12'
with Debian dir 7d40558cc14c1661625896c83ea590011cfa7a0a
- - - - -
5f0b6478 by Emmanuel Bourg at 2018-06-06T20:00:59+02:00
New upstream release (1.12)
- - - - -
3b083e96 by Emmanuel Bourg at 2018-06-06T20:04:35+02:00
Standards-Version updated to 4.1.4
- - - - -
375cc7cd by Emmanuel Bourg at 2018-06-06T20:05:15+02:00
Use salsa.debian.org Vcs-* URLs
- - - - -
6aa59655 by Emmanuel Bourg at 2018-06-06T20:10:29+02:00
Ignore the test failures to avoid the FTBFS with Java 9 (Closes: #893416)
- - - - -
688c897c by Emmanuel Bourg at 2018-06-06T20:11:02+02:00
Upload to unstable
- - - - -
23 changed files:
- debian/changelog
- debian/compat
- debian/control
- − debian/maven.cleanIgnoreRules
- debian/maven.properties
- − debian/maven.publishedRules
- debian/rules
- demo/api/pom.xml
- demo/app/pom.xml
- demo/plugin1/pom.xml
- demo/plugin2/pom.xml
- demo/pom.xml
- pom.xml
- sezpoz/pom.xml
- sezpoz/src/main/java/net/java/sezpoz/Index.java
- sezpoz/src/main/java/net/java/sezpoz/impl/Indexer6.java → sezpoz/src/main/java/net/java/sezpoz/impl/Indexer.java
- + sezpoz/src/main/java/net/java/sezpoz/impl/Inspector.java
- sezpoz/src/main/java/net/java/sezpoz/impl/SerAnnConst.java
- sezpoz/src/main/java/net/java/sezpoz/impl/SerAnnotatedElement.java
- sezpoz/src/main/resources/META-INF/services/javax.annotation.processing.Processor
- − sezpoz/src/test/java/net/java/sezpoz/impl/Indexer6Test.java
- sezpoz/src/test/java/net/java/sezpoz/impl/IndexerTestBase.java → sezpoz/src/test/java/net/java/sezpoz/impl/IndexerTest.java
- sezpoz/src/test/java/net/java/sezpoz/impl/TestUtils.java
Changes:
=====================================
debian/changelog
=====================================
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,15 @@
+sezpoz (1.12-1) unstable; urgency=medium
+
+ * Team upload.
+ * New upstream release
+ * Ignore the test failures to avoid the FTBFS with Java 9 (Closes: #893416)
+ * Build with the DH sequencer instead of CDBS
+ * Standards-Version updated to 4.1.4
+ * Switch to debhelper level 11
+ * Use salsa.debian.org Vcs-* URLs
+
+ -- Emmanuel Bourg <ebourg at apache.org> Wed, 06 Jun 2018 20:10:35 +0200
+
sezpoz (1.10-2) unstable; urgency=medium
* Team upload.
@@ -28,7 +40,7 @@ sezpoz (1.9-2) unstable; urgency=low
[James Page]
* Fix FTBFS with OpenJDK7:
- d/patches/fix-java7-compat.patch: Backported patch from upstream trunk
- to ensure tools.jar picked up during build process.
+ to ensure tools.jar picked up during build process.
* Updated my email address.
* Tidied up lintian warnings in d/control.
=====================================
debian/compat
=====================================
--- a/debian/compat
+++ b/debian/compat
@@ -1 +1 @@
-9
+11
=====================================
debian/control
=====================================
--- a/debian/control
+++ b/debian/control
@@ -3,11 +3,17 @@ Section: java
Priority: optional
Maintainer: Debian Java Maintainers <pkg-java-maintainers at lists.alioth.debian.org>
Uploaders: James Page <james.page at ubuntu.com>
-Build-Depends: cdbs, debhelper (>= 9), default-jdk, maven-debian-helper
-Build-Depends-Indep: default-jdk-doc, junit4, libmaven-javadoc-plugin-java, libanimal-sniffer-java
-Standards-Version: 3.9.6
-Vcs-Git: git://anonscm.debian.org/pkg-java/sezpoz.git
-Vcs-Browser: https://anonscm.debian.org/cgit/pkg-java/sezpoz.git
+Build-Depends:
+ debhelper (>= 11),
+ default-jdk,
+ default-jdk-doc,
+ junit4,
+ libanimal-sniffer-java,
+ libmaven-javadoc-plugin-java,
+ maven-debian-helper
+Standards-Version: 4.1.4
+Vcs-Git: https://salsa.debian.org/java-team/sezpoz.git
+Vcs-Browser: https://salsa.debian.org/java-team/sezpoz
Homepage: https://github.com/jglick/sezpoz
Package: libsezpoz-java
=====================================
debian/maven.cleanIgnoreRules deleted
=====================================
--- a/debian/maven.cleanIgnoreRules
+++ /dev/null
@@ -1,20 +0,0 @@
-# Maven ignore rules - ignore some Maven dependencies and plugins
-# Format of this file is:
-# [group] [artifact] [type] [version] [classifier] [scope]
-# where each element can be either
-# - the exact string, for example org.apache for the group, or 3.1
-# for the version. In this case, the element is simply matched
-# and left as it is
-# - * (the star character, alone). In this case, anything will
-# match and be left as it is. For example, using * on the
-# position of the artifact field will match any artifact id
-# All elements much match before a rule can be applied
-# Example rule: match jar with groupid= junit, artifactid= junit
-# and version starting with 3., this dependency is then removed
-# from the POM
-# junit junit jar s/3\\..*/3.x/
-
-net.java.sezpoz perftest jar * * *
-net.java.sezpoz.demo pom pom * * *
-org.jvnet.wagon-svn wagon-svn * * * *
-org.codehaus.mojo versions-maven-plugin * * * *
=====================================
debian/maven.properties
=====================================
--- a/debian/maven.properties
+++ b/debian/maven.properties
@@ -2,3 +2,4 @@
# For example:
# maven.test.skip=true
+maven.test.failure.ignore=true
=====================================
debian/maven.publishedRules deleted
=====================================
--- a/debian/maven.publishedRules
+++ /dev/null
@@ -1,19 +0,0 @@
-# Maven published rules - additional rules to publish, to help
-# the packaging work of Debian maintainers using mh_make
-# Format of this file is:
-# [group] [artifact] [type] [version] [classifier] [scope]
-# where each element can be either
-# - the exact string, for example org.apache for the group, or 3.1
-# for the version. In this case, the element is simply matched
-# and left as it is
-# - * (the star character, alone). In this case, anything will
-# match and be left as it is. For example, using * on the
-# position of the artifact field will match any artifact id
-# - a regular expression of the form s/match/replace/
-# in this case, elements that match are transformed using
-# the regex rule.
-# All elements much match before a rule can be applied
-# Example rule: match jar with groupid= junit, artifactid= junit
-# and version starting with 3., replacing the version with 3.x
-# junit junit jar s/3\\..*/3.x/
-
=====================================
debian/rules
=====================================
--- a/debian/rules
+++ b/debian/rules
@@ -1,10 +1,4 @@
#!/usr/bin/make -f
-include /usr/share/cdbs/1/rules/debhelper.mk
-include /usr/share/cdbs/1/class/maven.mk
-
-JAVA_HOME := /usr/lib/jvm/default-java
-DEB_MAVEN_DOC_TARGET := javadoc:jar javadoc:aggregate
-
-get-orig-source:
- uscan --download-version $(DEB_UPSTREAM_VERSION) --force-download --rename
+%:
+ dh $@
=====================================
demo/api/pom.xml
=====================================
--- a/demo/api/pom.xml
+++ b/demo/api/pom.xml
@@ -3,12 +3,12 @@
<parent>
<groupId>net.java.sezpoz.demo</groupId>
<artifactId>pom</artifactId>
- <version>1.10</version>
+ <version>1.12</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>api</artifactId>
<packaging>jar</packaging>
- <version>1.10</version>
+ <version>1.12</version>
<name>SezPoz Demo API</name>
<dependencies>
<dependency>
=====================================
demo/app/pom.xml
=====================================
--- a/demo/app/pom.xml
+++ b/demo/app/pom.xml
@@ -3,12 +3,12 @@
<parent>
<groupId>net.java.sezpoz.demo</groupId>
<artifactId>pom</artifactId>
- <version>1.10</version>
+ <version>1.12</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>app</artifactId>
<packaging>jar</packaging>
- <version>1.10</version>
+ <version>1.12</version>
<name>SezPoz Demo Application</name>
<dependencies>
<dependency>
=====================================
demo/plugin1/pom.xml
=====================================
--- a/demo/plugin1/pom.xml
+++ b/demo/plugin1/pom.xml
@@ -3,12 +3,12 @@
<parent>
<groupId>net.java.sezpoz.demo</groupId>
<artifactId>pom</artifactId>
- <version>1.10</version>
+ <version>1.12</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>plugin1</artifactId>
<packaging>jar</packaging>
- <version>1.10</version>
+ <version>1.12</version>
<name>SezPoz Demo Plugin #1</name>
<dependencies>
<dependency>
=====================================
demo/plugin2/pom.xml
=====================================
--- a/demo/plugin2/pom.xml
+++ b/demo/plugin2/pom.xml
@@ -3,12 +3,12 @@
<parent>
<groupId>net.java.sezpoz.demo</groupId>
<artifactId>pom</artifactId>
- <version>1.10</version>
+ <version>1.12</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>plugin2</artifactId>
<packaging>jar</packaging>
- <version>1.10</version>
+ <version>1.12</version>
<name>SezPoz Demo Plugin #2</name>
<dependencies>
<dependency>
=====================================
demo/pom.xml
=====================================
--- a/demo/pom.xml
+++ b/demo/pom.xml
@@ -3,13 +3,13 @@
<parent>
<groupId>net.java.sezpoz</groupId>
<artifactId>pom</artifactId>
- <version>1.10</version>
+ <version>1.12</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>net.java.sezpoz.demo</groupId>
<artifactId>pom</artifactId>
<packaging>pom</packaging>
- <version>1.10</version>
+ <version>1.12</version>
<name>SezPoz Demo</name>
<build>
<plugins>
=====================================
pom.xml
=====================================
--- a/pom.xml
+++ b/pom.xml
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
+ <prerequisites>
+ <maven>3.0</maven>
+ </prerequisites>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
@@ -9,7 +12,7 @@
<groupId>net.java.sezpoz</groupId>
<artifactId>pom</artifactId>
<packaging>pom</packaging>
- <version>1.10</version>
+ <version>1.12</version>
<name>SezPoz</name>
<url>https://github.com/jglick/sezpoz</url>
<description>SezPoz is a lightweight and simple-to-learn library that lets you perform modular service lookups.</description>
@@ -24,7 +27,7 @@
<connection>scm:git:git at github.com:jglick/sezpoz.git</connection>
<developerConnection>scm:git:git at github.com:jglick/sezpoz.git</developerConnection>
<url>git at github.com:jglick/sezpoz.git</url>
- <tag>pom-1.10</tag>
+ <tag>pom-1.12</tag>
</scm>
<licenses>
<license>
@@ -37,7 +40,7 @@
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
+ <version>3.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
@@ -45,40 +48,44 @@
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
- <version>2.3.1</version>
+ <version>2.6</version>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
- <version>2.7</version>
+ <version>2.10.3</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
- <version>2.5</version>
+ <version>2.7</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.8</version>
+ <version>2.19.1</version>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
- <version>2.4.1</version>
+ <version>3.0.0</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
- <version>2.5</version>
+ <version>2.8.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
- <version>2.3.1</version>
+ <version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
- <version>3.0-beta-3</version>
+ <version>3.5.1</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-release-plugin</artifactId>
+ <version>2.5.3</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
- <version>1.2</version>
+ <version>1.5.0</version>
</plugin>
</plugins>
</pluginManagement>
@@ -92,7 +99,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
- <version>1.2</version>
+ <version>2.2</version>
</plugin>
</plugins>
</reporting>
=====================================
sezpoz/pom.xml
=====================================
--- a/sezpoz/pom.xml
+++ b/sezpoz/pom.xml
@@ -3,26 +3,20 @@
<parent>
<groupId>net.java.sezpoz</groupId>
<artifactId>pom</artifactId>
- <version>1.10</version>
+ <version>1.12</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>sezpoz</artifactId>
<packaging>jar</packaging>
- <version>1.10</version>
+ <version>1.12</version>
<name>SezPoz Library</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.8.2</version>
+ <version>4.12</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>animal-sniffer-annotations</artifactId>
- <version>1.9</version>
- <type>jar</type>
- </dependency>
</dependencies>
<build>
<plugins>
@@ -36,7 +30,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
- <version>1.9</version>
+ <version>1.15</version>
<executions>
<execution>
<phase>package</phase>
@@ -63,6 +57,17 @@
<forkMode>pertest</forkMode>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>net.java.sezpoz.impl.Inspector</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
</plugins>
</build>
<reporting>
=====================================
sezpoz/src/main/java/net/java/sezpoz/Index.java
=====================================
--- a/sezpoz/src/main/java/net/java/sezpoz/Index.java
+++ b/sezpoz/src/main/java/net/java/sezpoz/Index.java
@@ -45,6 +45,7 @@ import java.util.NoSuchElementException;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
+import net.java.sezpoz.impl.Indexer;
import net.java.sezpoz.impl.SerAnnotatedElement;
/**
@@ -139,7 +140,7 @@ public final class Index<A extends Annotation,I> implements Iterable<IndexItem<A
}
if (ois == null) {
if (resources == null) {
- resources = loader.getResources("META-INF/annotations/" + annotation.getName());
+ resources = loader.getResources(Indexer.METAINF_ANNOTATIONS + annotation.getName());
}
if (!resources.hasMoreElements()) {
// Exhausted all streams.
=====================================
sezpoz/src/main/java/net/java/sezpoz/impl/Indexer6.java → sezpoz/src/main/java/net/java/sezpoz/impl/Indexer.java
=====================================
--- a/sezpoz/src/main/java/net/java/sezpoz/impl/Indexer6.java
+++ b/sezpoz/src/main/java/net/java/sezpoz/impl/Indexer.java
@@ -38,6 +38,7 @@ import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
+import java.io.Writer;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
@@ -54,7 +55,6 @@ import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedOptions;
-import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.AnnotationValue;
@@ -70,19 +70,18 @@ import javax.tools.Diagnostic.Kind;
import javax.tools.FileObject;
import javax.tools.StandardLocation;
import net.java.sezpoz.Indexable;
-import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
/**
* Processor for indexable annotations.
*/
- at IgnoreJRERequirement
- at SupportedSourceVersion(SourceVersion.RELEASE_6)
@SupportedAnnotationTypes("*")
@SupportedOptions("sezpoz.quiet")
-public class Indexer6 extends AbstractProcessor {
+public class Indexer extends AbstractProcessor {
+
+ public static final String METAINF_ANNOTATIONS = "META-INF/annotations/";
/** public for ServiceLoader */
- public Indexer6() {}
+ public Indexer() {}
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
@@ -102,15 +101,20 @@ public class Indexer6 extends AbstractProcessor {
}
}
// map from indexable annotation names, to actual uses
- Map<String,List<SerAnnotatedElement>> output = new HashMap<String,List<SerAnnotatedElement>>();
+ Map<String,Map<String,SerAnnotatedElement>> output = new TreeMap<String,Map<String,SerAnnotatedElement>>();
Map<String,Collection<Element>> originatingElementsByAnn = new HashMap<String,Collection<Element>>();
scan(annotations, originatingElementsByAnn, roundEnv, output);
write(output, originatingElementsByAnn);
return false;
}
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
+
private void scan(Set<? extends TypeElement> annotations, Map<String,Collection<Element>> originatingElementsByAnn,
- RoundEnvironment roundEnv, Map<String,List<SerAnnotatedElement>> output) {
+ RoundEnvironment roundEnv, Map<String,Map<String,SerAnnotatedElement>> output) {
for (TypeElement ann : annotations) {
AnnotationMirror indexable = null;
for (AnnotationMirror _indexable : processingEnv.getElementUtils().getAllAnnotationMirrors(ann)) {
@@ -146,9 +150,9 @@ public class Indexer6 extends AbstractProcessor {
continue;
}
originatingElements.add(elt);
- List<SerAnnotatedElement> existingOutput = output.get(annName);
+ Map<String,SerAnnotatedElement> existingOutput = output.get(annName);
if (existingOutput == null) {
- existingOutput = new ArrayList<SerAnnotatedElement>();
+ existingOutput = new TreeMap<String,SerAnnotatedElement>();
output.put(annName, existingOutput);
}
SerAnnotatedElement ser = makeSerAnnotatedElement(elt, ann);
@@ -157,18 +161,18 @@ public class Indexer6 extends AbstractProcessor {
(ser.memberName != null ? "." + ser.memberName : "") +
" indexed under " + annName.replace('$', '.'));
}
- existingOutput.add(ser);
+ existingOutput.put(ser.key(), ser);
}
}
}
- private void write(Map<String,List<SerAnnotatedElement>> output, Map<String,Collection<Element>> originatingElementsByAnn) {
- for (Map.Entry<String,List<SerAnnotatedElement>> outputEntry : output.entrySet()) {
+ private void write(Map<String,Map<String,SerAnnotatedElement>> output, Map<String,Collection<Element>> originatingElementsByAnn) {
+ for (Map.Entry<String,Map<String,SerAnnotatedElement>> outputEntry : output.entrySet()) {
String annName = outputEntry.getKey();
try {
- List<SerAnnotatedElement> elements = outputEntry.getValue();
+ Map<String,SerAnnotatedElement> elements = outputEntry.getValue();
try {
- FileObject in = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", "META-INF/annotations/" + annName);
+ FileObject in = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", METAINF_ANNOTATIONS + annName);
// Read existing annotations, for incremental compilation.
InputStream is = in.openInputStream();
try {
@@ -183,7 +187,9 @@ public class Indexer6 extends AbstractProcessor {
if (el == null) {
break;
}
- elements.add(el);
+ if (!elements.containsKey(el.key())) {
+ elements.put(el.key(), el);
+ }
}
} finally {
is.close();
@@ -192,12 +198,12 @@ public class Indexer6 extends AbstractProcessor {
// OK, created for the first time
}
FileObject out = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT,
- "", "META-INF/annotations/" + annName,
+ "", METAINF_ANNOTATIONS + annName,
originatingElementsByAnn.get(annName).toArray(new Element[0]));
OutputStream os = out.openOutputStream();
try {
ObjectOutputStream oos = new ObjectOutputStream(os);
- for (SerAnnotatedElement el : elements) {
+ for (SerAnnotatedElement el : elements.values()) {
oos.writeObject(el);
}
oos.writeObject(null);
@@ -205,6 +211,19 @@ public class Indexer6 extends AbstractProcessor {
} finally {
os.close();
}
+ out = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT,
+ "", METAINF_ANNOTATIONS + annName + ".txt",
+ originatingElementsByAnn.get(annName).toArray(new Element[0]));
+ Writer w = out.openWriter();
+ try {
+ w.write("# informational; use java -jar sezpoz.jar to see authoritative contents\n");
+ for (SerAnnotatedElement el : elements.values()) {
+ w.write(el.toString());
+ w.write('\n');
+ }
+ } finally {
+ w.close();
+ }
} catch (IOException x) {
processingEnv.getMessager().printMessage(Kind.ERROR, x.toString());
}
=====================================
sezpoz/src/main/java/net/java/sezpoz/impl/Inspector.java
=====================================
--- /dev/null
+++ b/sezpoz/src/main/java/net/java/sezpoz/impl/Inspector.java
@@ -0,0 +1,89 @@
+package net.java.sezpoz.impl;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.ObjectInput;
+import java.io.ObjectInputStream;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+/** CLI utility for inspecting binary SezPoz metadata. */
+public class Inspector {
+
+ private static final byte[] ZIP_MAGIC = {0x50, 0x4b, 0x03, 0x04};
+ private static final byte[] SER_MAGIC = {(byte) 0xac, (byte) 0xed, 0x00, 0x05};
+
+ public static void main(String[] args) throws Exception {
+ if (args.length == 0) {
+ System.err.println("Usage: java -jar sezpoz.jar [ something.jar | some.serialized.Annotation ]+");
+ }
+ for (String arg : args) {
+ System.out.println("--- " + arg);
+ byte[] magic = new byte[4];
+ InputStream is = new FileInputStream(arg);
+ try {
+ is.read(magic, 0, 4);
+ } finally {
+ is.close();
+ }
+ if (Arrays.equals(magic, ZIP_MAGIC)) {
+ JarFile jf = new JarFile(arg, false);
+ try {
+ Enumeration<JarEntry> entries = jf.entries();
+ while (entries.hasMoreElements()) {
+ JarEntry entry = entries.nextElement();
+ String name = entry.getName();
+ if (name.startsWith(Indexer.METAINF_ANNOTATIONS)) {
+ String annotation = name.substring(Indexer.METAINF_ANNOTATIONS.length());
+ if (annotation.isEmpty() || annotation.endsWith(".txt")) {
+ continue;
+ }
+ System.out.println("# " + annotation);
+ is = jf.getInputStream(entry);
+ try {
+ is.read(magic, 0, 4);
+ } finally {
+ is.close();
+ }
+ if ((Arrays.equals(magic, SER_MAGIC))) {
+ is = jf.getInputStream(entry);
+ try {
+ dump(is);
+ } finally {
+ is.close();
+ }
+ } else {
+ System.err.println("does not look like a Java serialized file");
+ }
+ }
+ }
+ } finally {
+ jf.close();
+ }
+ } else if (Arrays.equals(magic, SER_MAGIC)) {
+ is = new FileInputStream(arg);
+ try {
+ dump(is);
+ } finally {
+ is.close();
+ }
+ } else {
+ System.err.println("does not look like either a JAR file or a Java serialized file");
+ }
+ }
+ }
+
+ private static void dump(InputStream is) throws Exception {
+ ObjectInput oi = new ObjectInputStream(is);
+ while (true) {
+ SerAnnotatedElement el = (SerAnnotatedElement) oi.readObject();
+ if (el == null) {
+ break;
+ }
+ System.out.println(el);
+ }
+ }
+
+}
=====================================
sezpoz/src/main/java/net/java/sezpoz/impl/SerAnnConst.java
=====================================
--- a/sezpoz/src/main/java/net/java/sezpoz/impl/SerAnnConst.java
+++ b/sezpoz/src/main/java/net/java/sezpoz/impl/SerAnnConst.java
@@ -44,7 +44,7 @@ public final class SerAnnConst implements Serializable {
/** fully qualified name of annotation type */
public final String name;
- /** values of annotation attrs, as in {@link #SerAnnotatedElement} */
+ /** values of annotation attrs, as in {@link SerAnnotatedElement} */
public final TreeMap<String,Object> values;
SerAnnConst(String name, TreeMap<String,Object> values) {
=====================================
sezpoz/src/main/java/net/java/sezpoz/impl/SerAnnotatedElement.java
=====================================
--- a/sezpoz/src/main/java/net/java/sezpoz/impl/SerAnnotatedElement.java
+++ b/sezpoz/src/main/java/net/java/sezpoz/impl/SerAnnotatedElement.java
@@ -40,7 +40,7 @@ import java.util.TreeMap;
* One META-INF/annotations/* file is a sequence of serialized SerAnnotatedElement
* instances, terminated by a null.
*/
-public final class SerAnnotatedElement implements Serializable {
+public final class SerAnnotatedElement implements Serializable, Comparable<SerAnnotatedElement> {
private static final long serialVersionUID = 1L;
@@ -76,6 +76,13 @@ public final class SerAnnotatedElement implements Serializable {
}
public String toString() {
+ return values.isEmpty() ? key() : key() + values;
+ }
+
+ /**
+ * Key based on the annotated element, ignoring annotation values.
+ */
+ public String key() {
StringBuffer b = new StringBuffer(className);
if (memberName != null) {
b.append('#');
@@ -84,8 +91,11 @@ public final class SerAnnotatedElement implements Serializable {
b.append("()");
}
}
- b.append(values);
return b.toString();
}
+ @Override public int compareTo(SerAnnotatedElement o) {
+ return key().compareTo(o.key());
+ }
+
}
=====================================
sezpoz/src/main/resources/META-INF/services/javax.annotation.processing.Processor
=====================================
--- a/sezpoz/src/main/resources/META-INF/services/javax.annotation.processing.Processor
+++ b/sezpoz/src/main/resources/META-INF/services/javax.annotation.processing.Processor
@@ -1 +1 @@
-net.java.sezpoz.impl.Indexer6
+net.java.sezpoz.impl.Indexer
=====================================
sezpoz/src/test/java/net/java/sezpoz/impl/Indexer6Test.java deleted
=====================================
--- a/sezpoz/src/test/java/net/java/sezpoz/impl/Indexer6Test.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common
- * Development and Distribution License ("CDDL") (collectively, the
- * "License"). You may not use this file except in compliance with the
- * License. You can obtain a copy of the License at
- * http://www.netbeans.org/cddl-gplv2.html. See the License for the
- * specific language governing permissions and limitations under the
- * License. When distributing the software, include this License Header
- * Notice in each file. This particular file is subject to the "Classpath"
- * exception as provided in the GPL Version 2 section of the License file
- * that accompanied this code. If applicable, add the following below the
- * License Header, with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * The Original Software is SezPoz. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Copyright 2006-2011 Oracle
- * Corporation. All Rights Reserved.
- *
- * If you wish your version of this file to be governed by only the CDDL
- * or only the GPL Version 2, indicate your decision by adding
- * "[Contributor] elects to include this software in this distribution
- * under the [CDDL or GPL Version 2] license." If you do not indicate a
- * single choice of license, a recipient has the option to distribute
- * your version of this file under either the CDDL, the GPL Version 2 or
- * to extend the choice of license to its licensees as provided above.
- * However, if you add GPL Version 2 code and therefore, elected the GPL
- * Version 2 license, then the option applies only if the new code is
- * made subject to such option by the copyright holder.
- */
-
-package net.java.sezpoz.impl;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.TreeSet;
-import static org.junit.Assert.*;
-import org.junit.Test;
-
-/**
- * Test for JDK 6 (JSR 199) version of indexer.
- */
-public class Indexer6Test extends IndexerTestBase {
-
- @Test public void incrementalCompilation() throws Exception {
- File src1 = new File(dir, "src1");
- TestUtils.makeSource(src1, "Thing",
- "import java.lang.annotation.*;",
- "@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})",
- "@Retention(RetentionPolicy.SOURCE)",
- "@net.java.sezpoz.Indexable",
- "public @interface Thing {",
- "String name();",
- "}");
- File clz1 = new File(dir, "clz1");
- TestUtils.runApt(src1, null, clz1, null, null);
- File src2 = new File(dir, "src2");
- TestUtils.makeSource(src2, "Impl1",
- "@Thing(name=\"one\")",
- "public class Impl1 {}");
- File clz2 = new File(dir, "clz2");
- TestUtils.runApt(src2, null, clz2, new File[] {clz1}, null);
- assertEquals(Collections.singletonMap("Thing", Collections.singleton(
- "Impl1{name=one}"
- )), TestUtils.findMetadata(clz2));
- TestUtils.makeSource(src2, "Impl2",
- "@Thing(name=\"two\")",
- "public class Impl2 {}");
- TestUtils.runApt(src2, "Impl2", clz2, new File[] {clz1}, null);
- assertEquals(Collections.singletonMap("Thing", new TreeSet<String>(Arrays.asList(
- "Impl1{name=one}",
- "Impl2{name=two}"
- ))), TestUtils.findMetadata(clz2));
- }
-
- // XXX the following should be moved to IndexerTestBase when Indexer5 implements these things:
-
- @Test public void nonPublic() throws Exception {
- TestUtils.makeSource(src, "x.A",
- "import java.lang.annotation.*;",
- "@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})",
- "@Retention(RetentionPolicy.SOURCE)",
- "@net.java.sezpoz.Indexable",
- "public @interface A {}");
- TestUtils.makeSource(src, "y.C1", "@x.A public class C1 {}");
- TestUtils.makeSource(src, "y.C2", "@x.A class C2 {}");
- TestUtils.runApt(src, "A|C1", clz, null, null);
- TestUtils.runAptExpectingErrors(src, "A|C2", clz, null, "public");
- TestUtils.makeSource(src, "y.M1", "public class M1 {@x.A public static Object m() {return null;}}");
- TestUtils.makeSource(src, "y.M2", "public class M2 {@x.A static Object m() {return null;}}");
- TestUtils.makeSource(src, "y.M3", "public class M3 {@x.A protected static Object m() {return null;}}");
- TestUtils.makeSource(src, "y.M4", "public class M4 {@x.A private static Object m() {return null;}}");
- TestUtils.makeSource(src, "y.M5", "class M1 {@x.A public static Object m() {return null;}}");
- TestUtils.runApt(src, "A|M1", clz, null, null);
- TestUtils.runAptExpectingErrors(src, "A|M2", clz, null, "public");
- TestUtils.runAptExpectingErrors(src, "A|M3", clz, null, "public");
- TestUtils.runAptExpectingErrors(src, "A|M4", clz, null, "public");
- TestUtils.runAptExpectingErrors(src, "A|M5", clz, null, "public");
- TestUtils.makeSource(src, "y.F1", "public class F1 {@x.A public static final Object f = null;}");
- TestUtils.makeSource(src, "y.F2", "public class F2 {@x.A static final Object f = null;}");
- TestUtils.makeSource(src, "y.F3", "public class F3 {@x.A private static final Object f = null;}");
- TestUtils.makeSource(src, "y.F4", "class F4 {@x.A public static final Object f = null;}");
- TestUtils.runApt(src, "A|F1", clz, null, null);
- TestUtils.runAptExpectingErrors(src, "A|F2", clz, null, "public");
- TestUtils.runAptExpectingErrors(src, "A|F3", clz, null, "public");
- TestUtils.runAptExpectingErrors(src, "A|F4", clz, null, "public");
- }
-
- @Test public void inappropriateModifiersOrArgs() throws Exception {
- TestUtils.makeSource(src, "x.A",
- "import java.lang.annotation.*;",
- "@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})",
- "@Retention(RetentionPolicy.SOURCE)",
- "@net.java.sezpoz.Indexable",
- "public @interface A {}");
- TestUtils.makeSource(src, "y.C1", "@x.A public class C1 {}");
- TestUtils.makeSource(src, "y.C2", "@x.A public abstract class C2 {}");
- TestUtils.makeSource(src, "y.C3", "@x.A public class C3 {private C3() {}}");
- TestUtils.makeSource(src, "y.C4", "@x.A public class C4 {public C4(int x) {}}");
- TestUtils.runApt(src, "A|C1", clz, null, null);
- TestUtils.runAptExpectingErrors(src, "A|C2", clz, null, "abstract");
- TestUtils.runAptExpectingErrors(src, "A|C3", clz, null, "constructor");
- TestUtils.runAptExpectingErrors(src, "A|C4", clz, null, "constructor");
- TestUtils.makeSource(src, "y.M1", "public class M1 {@x.A public static Object m() {return null;}}");
- TestUtils.makeSource(src, "y.M2", "public class M2 {@x.A public Object m() {return null;}}");
- TestUtils.makeSource(src, "y.M3", "public class M3 {@x.A public static Object m(int x) {return null;}}");
- TestUtils.runApt(src, "A|M1", clz, null, null);
- TestUtils.runAptExpectingErrors(src, "A|M2", clz, null, "static");
- TestUtils.runAptExpectingErrors(src, "A|M3", clz, null, "parameters");
- TestUtils.makeSource(src, "y.F1", "public class F1 {@x.A public static final Object f = null;}");
- TestUtils.makeSource(src, "y.F2", "public class F2 {@x.A public final Object f = null;}");
- TestUtils.makeSource(src, "y.F3", "public class F3 {@x.A public static Object f = null;}");
- TestUtils.runApt(src, "A|F1", clz, null, null);
- TestUtils.runAptExpectingErrors(src, "A|F2", clz, null, "static");
- TestUtils.runAptExpectingErrors(src, "A|F3", clz, null, "final");
- TestUtils.makeSource(src, "y.N1", "public class N1 {@x.A public static class N {}}");
- TestUtils.makeSource(src, "y.N2", "public class N2 {@x.A public class N {}}");
- TestUtils.runApt(src, "A|N1", clz, null, null);
- TestUtils.runAptExpectingErrors(src, "A|N2", clz, null, "static");
- /* XXX 269 processors will not even see this:
- TestUtils.makeSource(src, "y.N3", "public class N3 {void m() {@x.A class N {}}}");
- TestUtils.runAptExpectingErrors(src, "A|N3", clz, null, "static", useJsr199());
- */
- }
-
- @Test public void incompatibleType() throws Exception {
- TestUtils.makeSource(src, "x.A",
- "import java.lang.annotation.*;",
- "@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})",
- "@Retention(RetentionPolicy.SOURCE)",
- "@net.java.sezpoz.Indexable(type=Runnable.class)",
- "public @interface A {}");
- TestUtils.makeSource(src, "y.C1", "@x.A public class C1 implements Runnable {public void run() {}}");
- TestUtils.makeSource(src, "y.C2", "@x.A public class C2 {}");
- TestUtils.runApt(src, "A|C1", clz, null, null);
- TestUtils.runAptExpectingErrors(src, "A|C2", clz, null, "Runnable");
- TestUtils.makeSource(src, "y.M1", "public class M1 {@x.A public static Runnable m() {return null;}}");
- TestUtils.makeSource(src, "y.M2", "public class M2 {@x.A public static Object m() {return null;}}");
- TestUtils.makeSource(src, "y.M3", "public class M3 implements Runnable {@x.A public static M3 m() {return null;} public void run() {}}");
- TestUtils.runApt(src, "A|M1", clz, null, null);
- TestUtils.runAptExpectingErrors(src, "A|M2", clz, null, "Runnable");
- TestUtils.runApt(src, "A|M3", clz, null, null);
- TestUtils.makeSource(src, "y.F1", "public class F1 {@x.A public static final Runnable f = null;}");
- TestUtils.makeSource(src, "y.F2", "public class F2 {@x.A public static final Object f = null;}");
- TestUtils.makeSource(src, "y.F3", "public class F3 implements Runnable {@x.A public static final F3 f = null; public void run() {}}");
- TestUtils.runApt(src, "A|F1", clz, null, null);
- TestUtils.runAptExpectingErrors(src, "A|F2", clz, null, "Runnable");
- TestUtils.runApt(src, "A|F3", clz, null, null);
- }
-
- @Test public void inappropriateIndexable() throws Exception {
- TestUtils.makeSource(src, "x.A1",
- "import java.lang.annotation.*;",
- "@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})",
- "@Retention(RetentionPolicy.SOURCE)",
- "@net.java.sezpoz.Indexable",
- "public @interface A1 {}");
- TestUtils.runApt(src, "A1", clz, null, null);
- TestUtils.makeSource(src, "x.A2",
- "import java.lang.annotation.*;",
- "@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})",
- "@Retention(RetentionPolicy.SOURCE)",
- "@Inherited",
- "@net.java.sezpoz.Indexable",
- "public @interface A2 {}");
- TestUtils.runAptExpectingErrors(src, "A2", clz, null, "@Inherited");
- TestUtils.makeSource(src, "x.A3",
- "import java.lang.annotation.*;",
- "@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR})",
- "@Retention(RetentionPolicy.SOURCE)",
- "@net.java.sezpoz.Indexable",
- "public @interface A3 {}");
- TestUtils.runAptExpectingErrors(src, "A3", clz, null, "CONSTRUCTOR");
- TestUtils.makeSource(src, "x.A4",
- "@net.java.sezpoz.Indexable",
- "@Retention(RetentionPolicy.SOURCE)",
- "public @interface A4 {}");
- TestUtils.runAptExpectingErrors(src, "A4", clz, null, "@Target");
- TestUtils.makeSource(src, "x.A5",
- "import java.lang.annotation.*;",
- "@Target({})",
- "@Retention(RetentionPolicy.SOURCE)",
- "@net.java.sezpoz.Indexable",
- "public @interface A5 {}");
- TestUtils.runAptExpectingErrors(src, "A5", clz, null, "@Target");
- TestUtils.makeSource(src, "x.A6",
- "import java.lang.annotation.*;",
- "@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})",
- "@net.java.sezpoz.Indexable",
- "public @interface A6 {}");
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- TestUtils.runApt(src, "A6", clz, null, baos);
- baos.flush();
- assertTrue("output warns about @Retention: " + baos, baos.toString().contains("@Retention"));
- }
-
-}
=====================================
sezpoz/src/test/java/net/java/sezpoz/impl/IndexerTestBase.java → sezpoz/src/test/java/net/java/sezpoz/impl/IndexerTest.java
=====================================
--- a/sezpoz/src/test/java/net/java/sezpoz/impl/IndexerTestBase.java
+++ b/sezpoz/src/test/java/net/java/sezpoz/impl/IndexerTest.java
@@ -32,21 +32,18 @@
package net.java.sezpoz.impl;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
-/**
- * Tries to run indexer and confirms that it serializes annotations correctly.
- */
-public abstract class IndexerTestBase {
+public class IndexerTest {
protected File dir, src, clz;
@Before public void setUp() throws Exception {
@@ -79,7 +76,7 @@ public abstract class IndexerTestBase {
"}");
File clz2 = new File(dir, "clz2");
TestUtils.runApt(src2, null, clz2, new File[] {clz1}, null);
- assertEquals(Collections.singletonMap("api.MenuItem", Collections.singleton(
+ assertEquals(Collections.singletonMap("api.MenuItem", Collections.singletonList(
"impl.PrintAction{iconPath=.../print.png, itemName=Print, menuName=File}"
)), TestUtils.findMetadata(clz2));
}
@@ -97,7 +94,7 @@ public abstract class IndexerTestBase {
"@x.A(x=\"foo\\\\\\\"\\n\")",
"public class C {}");
TestUtils.runApt(src, null, clz, null, null);
- assertEquals(Collections.singletonMap("x.A", Collections.singleton(
+ assertEquals(Collections.singletonMap("x.A", Collections.singletonList(
"y.C{x=foo\\\"\n}"
)), TestUtils.findMetadata(clz));
}
@@ -125,7 +122,7 @@ public abstract class IndexerTestBase {
"@A(other=@Other(v=1),others=@Other(v=2),i=3,b=true,c='x')",
"public class C {}");
TestUtils.runApt(src, null, clz, null, null);
- assertEquals(Collections.singletonMap("x.A", Collections.singleton(
+ assertEquals(Collections.singletonMap("x.A", Collections.singletonList(
"y.C{b=true, c=x, i=3, other=@x.Other{v=1}, others=[@x.Other{v=2}]}"
)), TestUtils.findMetadata(clz));
}
@@ -164,16 +161,16 @@ public abstract class IndexerTestBase {
"@B(as={@A, @A(), @A(i=20)})",
"public class C5 {}");
TestUtils.runApt(src, null, clz, null, null);
- Map<String,Set<String>> expected = new HashMap<String,Set<String>>();
- expected.put("x.A", new TreeSet<String>(Arrays.asList(new String[] {
+ Map<String,List<String>> expected = new HashMap<String,List<String>>();
+ expected.put("x.A", Arrays.asList(
"y.C1{i=33}",
- "y.C2{}",
- "y.C3{}",
- })));
- expected.put("x.B", new TreeSet<String>(Arrays.asList(new String[] {
- "y.C4{}",
+ "y.C2",
+ "y.C3"
+ ));
+ expected.put("x.B", Arrays.asList(
+ "y.C4",
"y.C5{as=[@x.A{}, @x.A{}, @x.A{i=20}]}"
- })));
+ ));
assertEquals(expected, TestUtils.findMetadata(clz));
}
@@ -194,7 +191,7 @@ public abstract class IndexerTestBase {
"@A(clazz=String.class,enoom={E.ONE,E.TWO})",
"public class C {}");
TestUtils.runApt(src, null, clz, null, null);
- assertEquals(Collections.singletonMap("x.A", Collections.singleton(
+ assertEquals(Collections.singletonMap("x.A", Collections.singletonList(
"y.C{clazz=java.lang.String, enoom=[ONE, TWO]}"
)), TestUtils.findMetadata(clz));
}
@@ -217,12 +214,12 @@ public abstract class IndexerTestBase {
"public static Object m() {return null;}",
"}");
TestUtils.runApt(src, null, clz, null, null);
- assertEquals(Collections.singletonMap("x.A", new TreeSet<String>(Arrays.asList(new String[] {
+ assertEquals(Collections.singletonMap("x.A", Arrays.asList(
"y.C#F{b=true}",
- "y.C#m(){b=false}",
- }))), TestUtils.findMetadata(clz));
+ "y.C#m(){b=false}"
+ )), TestUtils.findMetadata(clz));
}
-
+
@Test public void nestedClasses() throws Exception {
TestUtils.makeSource(src, "x.Outer",
"import java.lang.annotation.*;",
@@ -241,7 +238,7 @@ public abstract class IndexerTestBase {
"public static class C {}",
"}");
TestUtils.runApt(src, null, clz, null, null);
- assertEquals(Collections.singletonMap("x.Outer$A", Collections.singleton(
+ assertEquals(Collections.singletonMap("x.Outer$A", Collections.singletonList(
"y.Auter$C{type=y.Auter$T}"
)), TestUtils.findMetadata(clz));
}
@@ -267,4 +264,184 @@ public abstract class IndexerTestBase {
}
*/
+ @Test public void incrementalCompilation() throws Exception {
+ File src1 = new File(dir, "src1");
+ TestUtils.makeSource(src1, "Thing",
+ "import java.lang.annotation.*;",
+ "@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})",
+ "@Retention(RetentionPolicy.SOURCE)",
+ "@net.java.sezpoz.Indexable",
+ "public @interface Thing {",
+ "String name();",
+ "}");
+ File clz1 = new File(dir, "clz1");
+ TestUtils.runApt(src1, null, clz1, null, null);
+ File src2 = new File(dir, "src2");
+ TestUtils.makeSource(src2, "Impl1",
+ "@Thing(name=\"one\")",
+ "public class Impl1 {}");
+ File clz2 = new File(dir, "clz2");
+ TestUtils.runApt(src2, null, clz2, new File[] {clz1}, null);
+ assertEquals(Collections.singletonMap("Thing", Collections.singletonList(
+ "Impl1{name=one}"
+ )), TestUtils.findMetadata(clz2));
+ TestUtils.makeSource(src2, "Impl2",
+ "@Thing(name=\"two\")",
+ "public class Impl2 {}");
+ TestUtils.runApt(src2, "Impl2", clz2, new File[] {clz1}, null);
+ assertEquals(Collections.singletonMap("Thing", Arrays.asList(
+ "Impl1{name=one}",
+ "Impl2{name=two}"
+ )), TestUtils.findMetadata(clz2));
+ TestUtils.makeSource(src2, "Impl2",
+ "@Thing(name=\"Two\")",
+ "public class Impl2 {}");
+ TestUtils.runApt(src2, null, clz2, new File[] {clz1}, null);
+ assertEquals(Collections.singletonMap("Thing", Arrays.asList(
+ "Impl1{name=one}",
+ "Impl2{name=Two}"
+ )), TestUtils.findMetadata(clz2));
+ }
+
+ // XXX the following should be moved to IndexerTestBase when Indexer5 implements these things:
+
+ @Test public void nonPublic() throws Exception {
+ TestUtils.makeSource(src, "x.A",
+ "import java.lang.annotation.*;",
+ "@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})",
+ "@Retention(RetentionPolicy.SOURCE)",
+ "@net.java.sezpoz.Indexable",
+ "public @interface A {}");
+ TestUtils.makeSource(src, "y.C1", "@x.A public class C1 {}");
+ TestUtils.makeSource(src, "y.C2", "@x.A class C2 {}");
+ TestUtils.runApt(src, "A|C1", clz, null, null);
+ TestUtils.runAptExpectingErrors(src, "A|C2", clz, null, "public");
+ TestUtils.makeSource(src, "y.M1", "public class M1 {@x.A public static Object m() {return null;}}");
+ TestUtils.makeSource(src, "y.M2", "public class M2 {@x.A static Object m() {return null;}}");
+ TestUtils.makeSource(src, "y.M3", "public class M3 {@x.A protected static Object m() {return null;}}");
+ TestUtils.makeSource(src, "y.M4", "public class M4 {@x.A private static Object m() {return null;}}");
+ TestUtils.makeSource(src, "y.M5", "class M1 {@x.A public static Object m() {return null;}}");
+ TestUtils.runApt(src, "A|M1", clz, null, null);
+ TestUtils.runAptExpectingErrors(src, "A|M2", clz, null, "public");
+ TestUtils.runAptExpectingErrors(src, "A|M3", clz, null, "public");
+ TestUtils.runAptExpectingErrors(src, "A|M4", clz, null, "public");
+ TestUtils.runAptExpectingErrors(src, "A|M5", clz, null, "public");
+ TestUtils.makeSource(src, "y.F1", "public class F1 {@x.A public static final Object f = null;}");
+ TestUtils.makeSource(src, "y.F2", "public class F2 {@x.A static final Object f = null;}");
+ TestUtils.makeSource(src, "y.F3", "public class F3 {@x.A private static final Object f = null;}");
+ TestUtils.makeSource(src, "y.F4", "class F4 {@x.A public static final Object f = null;}");
+ TestUtils.runApt(src, "A|F1", clz, null, null);
+ TestUtils.runAptExpectingErrors(src, "A|F2", clz, null, "public");
+ TestUtils.runAptExpectingErrors(src, "A|F3", clz, null, "public");
+ TestUtils.runAptExpectingErrors(src, "A|F4", clz, null, "public");
+ }
+
+ @Test public void inappropriateModifiersOrArgs() throws Exception {
+ TestUtils.makeSource(src, "x.A",
+ "import java.lang.annotation.*;",
+ "@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})",
+ "@Retention(RetentionPolicy.SOURCE)",
+ "@net.java.sezpoz.Indexable",
+ "public @interface A {}");
+ TestUtils.makeSource(src, "y.C1", "@x.A public class C1 {}");
+ TestUtils.makeSource(src, "y.C2", "@x.A public abstract class C2 {}");
+ TestUtils.makeSource(src, "y.C3", "@x.A public class C3 {private C3() {}}");
+ TestUtils.makeSource(src, "y.C4", "@x.A public class C4 {public C4(int x) {}}");
+ TestUtils.runApt(src, "A|C1", clz, null, null);
+ TestUtils.runAptExpectingErrors(src, "A|C2", clz, null, "abstract");
+ TestUtils.runAptExpectingErrors(src, "A|C3", clz, null, "constructor");
+ TestUtils.runAptExpectingErrors(src, "A|C4", clz, null, "constructor");
+ TestUtils.makeSource(src, "y.M1", "public class M1 {@x.A public static Object m() {return null;}}");
+ TestUtils.makeSource(src, "y.M2", "public class M2 {@x.A public Object m() {return null;}}");
+ TestUtils.makeSource(src, "y.M3", "public class M3 {@x.A public static Object m(int x) {return null;}}");
+ TestUtils.runApt(src, "A|M1", clz, null, null);
+ TestUtils.runAptExpectingErrors(src, "A|M2", clz, null, "static");
+ TestUtils.runAptExpectingErrors(src, "A|M3", clz, null, "parameters");
+ TestUtils.makeSource(src, "y.F1", "public class F1 {@x.A public static final Object f = null;}");
+ TestUtils.makeSource(src, "y.F2", "public class F2 {@x.A public final Object f = null;}");
+ TestUtils.makeSource(src, "y.F3", "public class F3 {@x.A public static Object f = null;}");
+ TestUtils.runApt(src, "A|F1", clz, null, null);
+ TestUtils.runAptExpectingErrors(src, "A|F2", clz, null, "static");
+ TestUtils.runAptExpectingErrors(src, "A|F3", clz, null, "final");
+ TestUtils.makeSource(src, "y.N1", "public class N1 {@x.A public static class N {}}");
+ TestUtils.makeSource(src, "y.N2", "public class N2 {@x.A public class N {}}");
+ TestUtils.runApt(src, "A|N1", clz, null, null);
+ TestUtils.runAptExpectingErrors(src, "A|N2", clz, null, "static");
+ /* XXX 269 processors will not even see this:
+ TestUtils.makeSource(src, "y.N3", "public class N3 {void m() {@x.A class N {}}}");
+ TestUtils.runAptExpectingErrors(src, "A|N3", clz, null, "static", useJsr199());
+ */
+ }
+
+ @Test public void incompatibleType() throws Exception {
+ TestUtils.makeSource(src, "x.A",
+ "import java.lang.annotation.*;",
+ "@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})",
+ "@Retention(RetentionPolicy.SOURCE)",
+ "@net.java.sezpoz.Indexable(type=Runnable.class)",
+ "public @interface A {}");
+ TestUtils.makeSource(src, "y.C1", "@x.A public class C1 implements Runnable {public void run() {}}");
+ TestUtils.makeSource(src, "y.C2", "@x.A public class C2 {}");
+ TestUtils.runApt(src, "A|C1", clz, null, null);
+ TestUtils.runAptExpectingErrors(src, "A|C2", clz, null, "Runnable");
+ TestUtils.makeSource(src, "y.M1", "public class M1 {@x.A public static Runnable m() {return null;}}");
+ TestUtils.makeSource(src, "y.M2", "public class M2 {@x.A public static Object m() {return null;}}");
+ TestUtils.makeSource(src, "y.M3", "public class M3 implements Runnable {@x.A public static M3 m() {return null;} public void run() {}}");
+ TestUtils.runApt(src, "A|M1", clz, null, null);
+ TestUtils.runAptExpectingErrors(src, "A|M2", clz, null, "Runnable");
+ TestUtils.runApt(src, "A|M3", clz, null, null);
+ TestUtils.makeSource(src, "y.F1", "public class F1 {@x.A public static final Runnable f = null;}");
+ TestUtils.makeSource(src, "y.F2", "public class F2 {@x.A public static final Object f = null;}");
+ TestUtils.makeSource(src, "y.F3", "public class F3 implements Runnable {@x.A public static final F3 f = null; public void run() {}}");
+ TestUtils.runApt(src, "A|F1", clz, null, null);
+ TestUtils.runAptExpectingErrors(src, "A|F2", clz, null, "Runnable");
+ TestUtils.runApt(src, "A|F3", clz, null, null);
+ }
+
+ @Test public void inappropriateIndexable() throws Exception {
+ TestUtils.makeSource(src, "x.A1",
+ "import java.lang.annotation.*;",
+ "@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})",
+ "@Retention(RetentionPolicy.SOURCE)",
+ "@net.java.sezpoz.Indexable",
+ "public @interface A1 {}");
+ TestUtils.runApt(src, "A1", clz, null, null);
+ TestUtils.makeSource(src, "x.A2",
+ "import java.lang.annotation.*;",
+ "@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})",
+ "@Retention(RetentionPolicy.SOURCE)",
+ "@Inherited",
+ "@net.java.sezpoz.Indexable",
+ "public @interface A2 {}");
+ TestUtils.runAptExpectingErrors(src, "A2", clz, null, "@Inherited");
+ TestUtils.makeSource(src, "x.A3",
+ "import java.lang.annotation.*;",
+ "@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR})",
+ "@Retention(RetentionPolicy.SOURCE)",
+ "@net.java.sezpoz.Indexable",
+ "public @interface A3 {}");
+ TestUtils.runAptExpectingErrors(src, "A3", clz, null, "CONSTRUCTOR");
+ TestUtils.makeSource(src, "x.A4",
+ "@net.java.sezpoz.Indexable",
+ "@Retention(RetentionPolicy.SOURCE)",
+ "public @interface A4 {}");
+ TestUtils.runAptExpectingErrors(src, "A4", clz, null, "@Target");
+ TestUtils.makeSource(src, "x.A5",
+ "import java.lang.annotation.*;",
+ "@Target({})",
+ "@Retention(RetentionPolicy.SOURCE)",
+ "@net.java.sezpoz.Indexable",
+ "public @interface A5 {}");
+ TestUtils.runAptExpectingErrors(src, "A5", clz, null, "@Target");
+ TestUtils.makeSource(src, "x.A6",
+ "import java.lang.annotation.*;",
+ "@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})",
+ "@net.java.sezpoz.Indexable",
+ "public @interface A6 {}");
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ TestUtils.runApt(src, "A6", clz, null, baos);
+ baos.flush();
+ assertTrue("output warns about @Retention: " + baos, baos.toString().contains("@Retention"));
+ }
+
}
=====================================
sezpoz/src/test/java/net/java/sezpoz/impl/TestUtils.java
=====================================
--- a/sezpoz/src/test/java/net/java/sezpoz/impl/TestUtils.java
+++ b/sezpoz/src/test/java/net/java/sezpoz/impl/TestUtils.java
@@ -184,20 +184,23 @@ public class TestUtils {
/**
* Find contents of META-INF/annotations/* in a dest dir.
- * @return map from simple file names to set of SerAnnotatedElement.toString()s
+ * @return map from simple file names to list of {@link SerAnnotatedElement#toString}s
*/
- public static Map<String,SortedSet<String>> findMetadata(File dest) throws Exception {
+ public static Map<String,List<String>> findMetadata(File dest) throws Exception {
File dir = new File(new File(dest, "META-INF"), "annotations");
if (!dir.isDirectory()) {
return Collections.emptyMap();
}
- Map<String,SortedSet<String>> metadata = new HashMap<String,SortedSet<String>>();
+ Map<String,List<String>> metadata = new HashMap<String,List<String>>();
for (String kid : dir.list()) {
+ if (kid.endsWith(".txt")) {
+ continue;
+ }
File f = new File(dir, kid);
InputStream is = new FileInputStream(f);
try {
ObjectInputStream ois = new ObjectInputStream(is);
- SortedSet<String> entries = new TreeSet<String>();
+ List<String> entries = new ArrayList<String>();
while (true) {
SerAnnotatedElement el = (SerAnnotatedElement) ois.readObject();
if (el == null) {
View it on GitLab: https://salsa.debian.org/java-team/sezpoz/compare/697de7684074a8cd58f3478f8bc3db7bc764af6d...688c897c747574f24ac84160f107b754f26afe11
--
View it on GitLab: https://salsa.debian.org/java-team/sezpoz/compare/697de7684074a8cd58f3478f8bc3db7bc764af6d...688c897c747574f24ac84160f107b754f26afe11
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20180606/ad330c32/attachment.html>
More information about the pkg-java-commits
mailing list