diff -Nru sezpoz-1.9/debian/changelog sezpoz-1.10/debian/changelog --- sezpoz-1.9/debian/changelog 2011-12-30 19:39:22.000000000 +0000 +++ sezpoz-1.10/debian/changelog 2015-04-28 07:37:06.000000000 +0000 @@ -1,3 +1,28 @@ +sezpoz (1.10-2) unstable; urgency=medium + + * Team upload. + * Upload to unstable + + -- Emmanuel Bourg Tue, 28 Apr 2015 09:36:48 +0200 + +sezpoz (1.10-1) experimental; urgency=medium + + * Team upload. + * New upstream release + - Fixes the Java 8 compatibility (Closes: #750745) + - Removed the Java 7 compatibility patch (fixed upstream) + - New build dependency on libanimal-sniffer-java + * debian/control: + - Standards-Version updated to 3.9.6 (no changes) + - Removed the deprecated DM-Upload-Allowed field + - Use canonical URLs for the Vcs-* fields + - Updated the Homepage field + * debian/watch: Watch the release tags on GitHub + * debian/copyright: Use the Copyright Format 1.0 URL + * Switch to debhelper level 9 + + -- Emmanuel Bourg Thu, 02 Apr 2015 17:42:21 +0200 + sezpoz (1.9-2) unstable; urgency=low [James Page] diff -Nru sezpoz-1.9/debian/compat sezpoz-1.10/debian/compat --- sezpoz-1.9/debian/compat 2011-12-30 19:39:22.000000000 +0000 +++ sezpoz-1.10/debian/compat 2015-04-02 14:30:19.000000000 +0000 @@ -1 +1 @@ -7 +9 diff -Nru sezpoz-1.9/debian/control sezpoz-1.10/debian/control --- sezpoz-1.9/debian/control 2011-12-30 19:39:22.000000000 +0000 +++ sezpoz-1.10/debian/control 2015-04-02 15:38:26.000000000 +0000 @@ -3,13 +3,12 @@ Priority: optional Maintainer: Debian Java Maintainers Uploaders: James Page -DM-Upload-Allowed: yes -Build-Depends: cdbs, debhelper (>= 7), default-jdk, maven-debian-helper -Build-Depends-Indep: default-jdk-doc, junit4, libmaven-javadoc-plugin-java -Standards-Version: 3.9.2 -Homepage: http://sezpoz.java.net/ -Vcs-Git: git://git.debian.org/git/pkg-java/sezpoz.git -Vcs-Browser: http://git.debian.org/?p=pkg-java/sezpoz.git +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 +Homepage: https://github.com/jglick/sezpoz Package: libsezpoz-java Architecture: all diff -Nru sezpoz-1.9/debian/copyright sezpoz-1.10/debian/copyright --- sezpoz-1.9/debian/copyright 2011-12-30 19:39:22.000000000 +0000 +++ sezpoz-1.10/debian/copyright 2015-04-02 15:29:27.000000000 +0000 @@ -1,7 +1,7 @@ -Format: http://dep.debian.net/deps/dep5/ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: SezPoz Upstream-Contact: Jesse Glick as Developer -Source: https://sezpoz.java.net/ +Source: https://github.com/jglick/sezpoz Files: * Copyright: 2010, Jesse Glick , diff -Nru sezpoz-1.9/debian/libsezpoz-java.poms sezpoz-1.10/debian/libsezpoz-java.poms --- sezpoz-1.9/debian/libsezpoz-java.poms 2011-12-30 19:39:22.000000000 +0000 +++ sezpoz-1.10/debian/libsezpoz-java.poms 2015-04-28 07:37:58.000000000 +0000 @@ -2,7 +2,9 @@ # Format of this file is: # [option]* # where option can be: -# --ignore: ignore this POM or +# --ignore: ignore this POM and its artifact if any +# --ignore-pom: don't install the POM. To use on POM files that are created +# temporarily for certain artifacts such as Javadoc jars. [mh_install, mh_installpoms] # --no-parent: remove the tag from the POM # --package=: an alternative package to use when installing this POM # and its artifact @@ -11,15 +13,19 @@ # --keep-elements=: a list of XML elements to keep in the POM # during a clean operation with mh_cleanpom or mh_installpom # --artifact=: path to the build artifact associated with this POM, -# it will be installed when using the command mh_install +# it will be installed when using the command mh_install. [mh_install] # --java-lib: install the jar into /usr/share/java to comply with Debian # packaging guidelines # --usj-name=: name to use when installing the library in /usr/share/java # --usj-version=: version to use when installing the library in /usr/share/java # --no-usj-versionless: don't install the versionless link in /usr/share/java -# --dest-jar=: the destination for the real jar +# --dest-jar=: the destination for the real jar. +# It will be installed with mh_install. [mh_install] +# --classifier=: Optional, the classifier for the jar. Empty by default. +# --site-xml=: Optional, the location for site.xml if it needs to be installed. +# Empty by default. [mh_install] # -pom.xml --no-parent -sezpoz/pom.xml +pom.xml --no-parent +sezpoz/pom.xml --has-package-version --java-lib perftest/pom.xml --ignore demo/pom.xml --ignore diff -Nru sezpoz-1.9/debian/maven.ignoreRules sezpoz-1.10/debian/maven.ignoreRules --- sezpoz-1.9/debian/maven.ignoreRules 2011-12-30 19:39:22.000000000 +0000 +++ sezpoz-1.10/debian/maven.ignoreRules 2015-04-28 07:38:40.000000000 +0000 @@ -16,5 +16,6 @@ net.java.sezpoz perftest jar * * * net.java.sezpoz.demo pom pom * * * -org.jvnet.wagon-svn wagon-svn * * * * +org.codehaus.mojo animal-sniffer-maven-plugin * * * * org.codehaus.mojo versions-maven-plugin * * * * +org.jvnet.wagon-svn wagon-svn * * * * diff -Nru sezpoz-1.9/debian/orig-tar.sh sezpoz-1.10/debian/orig-tar.sh --- sezpoz-1.9/debian/orig-tar.sh 2011-12-30 19:39:22.000000000 +0000 +++ sezpoz-1.10/debian/orig-tar.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -#!/bin/sh -e - -VERSION=$2 -TAR=../sezpoz_$VERSION.orig.tar.gz -DIR=sezpoz-$VERSION -TAG=$(echo "pom-$VERSION" | sed -re's/~(alpha|beta)/-\1-/') - -svn export https://svn.java.net/svn/sezpoz~svn/tags/${TAG}/ $DIR -GZIP=--best tar -c -z -f $TAR --exclude '*.jar' --exclude '*.class' $DIR -rm -rf $DIR ../$TAG - -# move to directory 'tarballs' -if [ -r .svn/deb-layout ]; then - . .svn/deb-layout - mv $TAR $origDir && echo "moved $TAR to $origDir" -fi diff -Nru sezpoz-1.9/debian/patches/build.patch sezpoz-1.10/debian/patches/build.patch --- sezpoz-1.9/debian/patches/build.patch 2011-12-30 19:39:22.000000000 +0000 +++ sezpoz-1.10/debian/patches/build.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -Description: Disable performance testing and demo elements - of build process as not required for packaging and pull extra - depends. -Author: James Page -Forwarded: not-needed - -Index: sezpoz/pom.xml -=================================================================== ---- sezpoz.orig/pom.xml 2011-03-17 13:18:17.000000000 +0000 -+++ sezpoz/pom.xml 2011-06-03 13:13:44.102717856 +0100 -@@ -105,7 +105,5 @@ - - - sezpoz -- -- demo - - diff -Nru sezpoz-1.9/debian/patches/fix-java7-compat.patch sezpoz-1.10/debian/patches/fix-java7-compat.patch --- sezpoz-1.9/debian/patches/fix-java7-compat.patch 2011-12-30 19:39:22.000000000 +0000 +++ sezpoz-1.10/debian/patches/fix-java7-compat.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -Description: Fix compilation error on JDK 7u1. - (${java.vendor} is now "Oracle Corporation".) -Author: jglick -Origin: http://java.net/projects/sezpoz/sources/svn/revision/156 - ---- a/sezpoz/pom.xml (revision 155) -+++ b/sezpoz/pom.xml (revision 156) -@@ -14,10 +14,9 @@ - - default-tools.jar - -- -- java.vendor -- Sun Microsystems Inc. -- -+ -+ ${java.home}/../lib/tools.jar -+ - - - diff -Nru sezpoz-1.9/debian/patches/series sezpoz-1.10/debian/patches/series --- sezpoz-1.9/debian/patches/series 2011-12-30 19:39:22.000000000 +0000 +++ sezpoz-1.10/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -build.patch -fix-java7-compat.patch diff -Nru sezpoz-1.9/debian/README.source sezpoz-1.10/debian/README.source --- sezpoz-1.9/debian/README.source 2011-12-30 19:39:22.000000000 +0000 +++ sezpoz-1.10/debian/README.source 2015-04-02 15:42:41.000000000 +0000 @@ -1,5 +1,5 @@ Information about sezpoz ------------------------------- +------------------------ This package was debianized using the mh_make command from the maven-debian-helper package. diff -Nru sezpoz-1.9/debian/watch sezpoz-1.10/debian/watch --- sezpoz-1.9/debian/watch 2011-12-30 19:39:22.000000000 +0000 +++ sezpoz-1.10/debian/watch 2015-04-02 14:30:19.000000000 +0000 @@ -1,4 +1,2 @@ version=3 -opts="uversionmangle=s/-(alpha|beta)-/~$1/" \ - http://java.net/projects/sezpoz/sources/svn/show/tags \ - /projects/sezpoz/sources/svn/show/tags/pom-(\d+).(\d+).* debian debian/orig-tar.sh +https://github.com/jglick/sezpoz/releases .*/pom-([\d\.]+).tar.gz diff -Nru sezpoz-1.9/demo/api/pom.xml sezpoz-1.10/demo/api/pom.xml --- sezpoz-1.9/demo/api/pom.xml 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/demo/api/pom.xml 2015-03-31 21:06:50.000000000 +0000 @@ -3,12 +3,12 @@ net.java.sezpoz.demo pom - 1.9 + 1.10 4.0.0 api jar - 1.9 + 1.10 SezPoz Demo API diff -Nru sezpoz-1.9/demo/app/pom.xml sezpoz-1.10/demo/app/pom.xml --- sezpoz-1.9/demo/app/pom.xml 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/demo/app/pom.xml 2015-03-31 21:06:50.000000000 +0000 @@ -3,12 +3,12 @@ net.java.sezpoz.demo pom - 1.9 + 1.10 4.0.0 app jar - 1.9 + 1.10 SezPoz Demo Application diff -Nru sezpoz-1.9/demo/plugin1/pom.xml sezpoz-1.10/demo/plugin1/pom.xml --- sezpoz-1.9/demo/plugin1/pom.xml 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/demo/plugin1/pom.xml 2015-03-31 21:06:50.000000000 +0000 @@ -3,12 +3,12 @@ net.java.sezpoz.demo pom - 1.9 + 1.10 4.0.0 plugin1 jar - 1.9 + 1.10 SezPoz Demo Plugin #1 diff -Nru sezpoz-1.9/demo/plugin2/pom.xml sezpoz-1.10/demo/plugin2/pom.xml --- sezpoz-1.9/demo/plugin2/pom.xml 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/demo/plugin2/pom.xml 2015-03-31 21:06:50.000000000 +0000 @@ -3,12 +3,12 @@ net.java.sezpoz.demo pom - 1.9 + 1.10 4.0.0 plugin2 jar - 1.9 + 1.10 SezPoz Demo Plugin #2 diff -Nru sezpoz-1.9/demo/pom.xml sezpoz-1.10/demo/pom.xml --- sezpoz-1.9/demo/pom.xml 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/demo/pom.xml 2015-03-31 21:06:50.000000000 +0000 @@ -3,13 +3,13 @@ net.java.sezpoz pom - 1.9 + 1.10 4.0.0 net.java.sezpoz.demo pom pom - 1.9 + 1.10 SezPoz Demo diff -Nru sezpoz-1.9/.gitignore sezpoz-1.10/.gitignore --- sezpoz-1.9/.gitignore 1970-01-01 00:00:00.000000000 +0000 +++ sezpoz-1.10/.gitignore 2015-03-31 21:06:50.000000000 +0000 @@ -0,0 +1,4 @@ +.classpath +.project +.settings/ +target/ diff -Nru sezpoz-1.9/perftest/pom.xml sezpoz-1.10/perftest/pom.xml --- sezpoz-1.9/perftest/pom.xml 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/perftest/pom.xml 2015-03-31 21:06:50.000000000 +0000 @@ -3,7 +3,7 @@ net.java.sezpoz pom - 1.9-SNAPSHOT + 1.9 4.0.0 perftest @@ -14,7 +14,7 @@ net.java.sezpoz sezpoz - 1.4 + 1.9 diff -Nru sezpoz-1.9/pom.xml sezpoz-1.10/pom.xml --- sezpoz-1.9/pom.xml 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/pom.xml 2015-03-31 21:06:50.000000000 +0000 @@ -4,31 +4,28 @@ org.sonatype.oss oss-parent - 7 + 9 net.java.sezpoz pom pom - 1.9 + 1.10 SezPoz - http://sezpoz.java.net/ + https://github.com/jglick/sezpoz SezPoz is a lightweight and simple-to-learn library that lets you perform modular service lookups. - jesse.glick@oracle.com + jglick@cloudbees.com Jesse Glick jglick - scm:svn:http://svn.java.net/svn/sezpoz~svn/tags/pom-1.9 - scm:svn:https://svn.java.net/svn/sezpoz~svn/tags/pom-1.9 - http://java.net/projects/sezpoz/sources/svn/show/tags/pom-1.9 - - - JIRA - http://java.net/jira/browse/SEZPOZ - + scm:git:git@github.com:jglick/sezpoz.git + scm:git:git@github.com:jglick/sezpoz.git + git@github.com:jglick/sezpoz.git + pom-1.10 + CDDL or GPL 2 with Classpath Exception @@ -40,17 +37,13 @@ maven-compiler-plugin - 2.3.1 + 2.3.2 - 1.5 - 1.5 + 1.6 + 1.6 - maven-release-plugin - 2.0 - - maven-jar-plugin 2.3.1 @@ -60,11 +53,11 @@ maven-resources-plugin - 2.4.3 + 2.5 maven-surefire-plugin - 2.5 + 2.8 maven-clean-plugin @@ -80,7 +73,7 @@ maven-site-plugin - 2.1.1 + 3.0-beta-3 org.codehaus.mojo diff -Nru sezpoz-1.9/README.md sezpoz-1.10/README.md --- sezpoz-1.9/README.md 1970-01-01 00:00:00.000000000 +0000 +++ sezpoz-1.10/README.md 2015-03-31 21:06:50.000000000 +0000 @@ -0,0 +1,117 @@ +SezPoz is a lightweight and easy-to-learn library that lets you perform modular service lookups. It provides some of the same capabilities as (for example) `java.util.ServiceLoader`, Eclipse extension points, and NetBeans `Lookup` and XML layers. However, SezPoz has some special advantages: + +1. The service registrations are made just using type-checked Java annotations. There are no configuration files to edit, and your Java IDE can show you registrations since they are simply usages of an annotation. On JDK 6 (or later), no special build or packaging steps are required (just javac). Looking up services just requires that you have a `ClassLoader` which can "see" all of the "modules" (as with `ServiceLoader`). + +2. You can register individual objects (values of static fields or methods) instead of whole classes. + +3. You can associate static metadata with each implementation, using regular annotation values. The caller can choose to inspect the metadata without loading the actual implementation object (as with Eclipse extension points). + +(Why the name? SezPoz "says" the "position" of your services. It is also a "[seznam][1] [poznámek][2]".) + +Sources are in the form of Maven projects. To build: + + mvn install + +To try the demo application: + + mvn -f demo/app/pom.xml exec:exec + +Binaries, sources, and Javadoc can all be downloaded from the Maven Central repository: [Maven repository][3]. + +For usage from Maven applications, use the artifact `net.java.sezpoz:sezpoz`, for example: + + + + net.java.sezpoz + sezpoz + …latest available… + + + +See Javadoc for details on particular classes, or just look at demo sources in the `demo` subdirectory in Subversion. + +Support for declaring, creating, and inspecting indices of annotated Java elements. + +For example, to permit registration of simple menu items, while making it possible to prepare a menu without loading any of them until they are actually selected: + + @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD}) + @Retention(RetentionPolicy.SOURCE) + @Indexable(type=ActionListener.class) + public @interface MenuItem { + String menuName(); + String itemName(); + String iconPath() default ""; + } + +A concrete registration might look like: + + @MenuItem(menuName="File", itemName="Print", iconPath=".../print.png") + public class PrintAction extends AbstractAction { + public void actionPerformed(ActionEvent e) {...} + } + +Alternatively: + + public class Actions { + @MenuItem(menuName="File", itemName="Print") + public static Action print() {...} + } + +or even: + + public class Actions { + @MenuItem(menuName="File", itemName="Print") + public static final Action PRINT = ...; + } + +To create the index on JDK 6+, just compile your sources normally with javac. (The processor is in the same JAR as this API and should be autodetected.) + +Usage is then simple: + + for (final IndexItem item : + Index.load(MenuItem.class, ActionListener.class)) { + JMenu menu = new JMenu(item.annotation().menuName()); + JMenuItem menuitem = new JMenuItem(item.annotation().itemName()); + String icon = item.annotation().iconPath(); + if (!icon.equals("")) { + menuitem.setIcon(new ImageIcon(icon)); + } + menuitem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + item.instance().actionPerformed(e); + } catch (InstantiationException x) { + x.printStackTrace(); + } + } + }); + } + + +Known limitations: + +1. Incremental compilation is not perfect. If you compile just some sources which are marked with an indexable annotation, these entries will be appended to any existing registrations from previous runs of the compiler. (You should run a clean build if you *delete* annotations from sources.) + +2. The Java language spec currently prohibits recursive annotation definitions, and JDK 6 and 7's javac enforce this. See [bug #6264216][4]. + +Eclipse-specific notes: make sure annotation processing is enabled at least for any projects registering objects using annotations. Make sure the SezPoz library is in the factory path for annotation processors. You also need to check the box **Run this container's processor in batch mode** from the **Advanced** button in **Java Compiler » Annotation Processing » Factory Path**. There does not appear to be any way for Eclipse to discover processors in the regular classpath as JSR 269 suggests, and there does not appear to be any way to make these settings apply automatically to all projects. Eclipse users are recommended to use javac (e.g. via Maven) to build. [Eclipse Help Page][5] [Eclipse bug #280542][6] + +SezPoz is used inside Hudson/Jenkins for the `@Extension` annotation, but this usage does not take advantage of its lazy-loading capability at all. + +[GlassFish/DependencyMechanism][7] looks a bit similar. In active use? + +[JPF][8] is similar to Eclipse, but can be used in isolation. + +[OSGi Declarative Services][9] can use Java annotations to register services, but static metadata looks weak compared to SezPoz. + +To be investigated: interoperability with Peaberry and/or Sisu. + + [1]: http://slovnik.seznam.cz/search.py?wd=seznam&lg=cz_en + [2]: http://slovnik.seznam.cz/search.py?wd=pozn%C3%A1mka&lg=cz_en + [3]: http://repo1.maven.org/maven2/net/java/sezpoz/sezpoz/ + [4]: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6264216 + [5]: http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclipse.jdt.doc.isv/guide/jdt_apt_getting_started.htm + [6]: https://bugs.eclipse.org/bugs/show_bug.cgi?id=280542 + [7]: https://wikis.oracle.com/display/GlassFish/DependencyMechanism + [8]: http://jpf.sourceforge.net/ + [9]: http://wiki.osgi.org/wiki/Declarative_Services diff -Nru sezpoz-1.9/sezpoz/pom.xml sezpoz-1.10/sezpoz/pom.xml --- sezpoz-1.9/sezpoz/pom.xml 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/sezpoz/pom.xml 2015-03-31 21:06:50.000000000 +0000 @@ -3,41 +3,26 @@ net.java.sezpoz pom - 1.9 + 1.10 4.0.0 sezpoz jar - 1.9 + 1.10 SezPoz Library - - - default-tools.jar - - - java.vendor - Sun Microsystems Inc. - - - - - sun.jdk - tools - 1.5.0 - system - ${java.home}/../lib/tools.jar - true - - - - junit junit - 4.8.1 + 4.8.2 test + + org.codehaus.mojo + animal-sniffer-annotations + 1.9 + jar + @@ -49,6 +34,26 @@ + org.codehaus.mojo + animal-sniffer-maven-plugin + 1.9 + + + package + + check + + + + org.codehaus.mojo.signature + java16 + 1.0 + + + + + + org.apache.maven.plugins maven-surefire-plugin @@ -56,8 +61,6 @@ **/TestUtils.java pertest - - -ea -Xbootclasspath/a:${java.home}/../lib/tools.jar diff -Nru sezpoz-1.9/sezpoz/src/main/java/net/java/sezpoz/impl/Indexer5.java sezpoz-1.10/sezpoz/src/main/java/net/java/sezpoz/impl/Indexer5.java --- sezpoz-1.9/sezpoz/src/main/java/net/java/sezpoz/impl/Indexer5.java 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/sezpoz/src/main/java/net/java/sezpoz/impl/Indexer5.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,209 +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. Portions Copyright 2006-2010 Sun - * Microsystems, Inc. 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 com.sun.mirror.apt.AnnotationProcessor; -import com.sun.mirror.apt.AnnotationProcessorEnvironment; -import com.sun.mirror.apt.Filer; -import com.sun.mirror.declaration.AnnotationMirror; -import com.sun.mirror.declaration.AnnotationTypeDeclaration; -import com.sun.mirror.declaration.AnnotationTypeElementDeclaration; -import com.sun.mirror.declaration.AnnotationValue; -import com.sun.mirror.declaration.Declaration; -import com.sun.mirror.declaration.EnumConstantDeclaration; -import com.sun.mirror.declaration.FieldDeclaration; -import com.sun.mirror.declaration.MethodDeclaration; -import com.sun.mirror.declaration.TypeDeclaration; -import com.sun.mirror.type.DeclaredType; -import com.sun.mirror.type.TypeMirror; -import java.io.File; -import java.io.IOException; -import java.io.ObjectOutputStream; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; -import net.java.sezpoz.Indexable; - -/** - * Processor for indexable annotations. - */ -class Indexer5 implements AnnotationProcessor { - - private final AnnotationProcessorEnvironment env; - /** map from indexable annotation names, to actual uses */ - private final Map> output; - - public Indexer5(Set ignore, AnnotationProcessorEnvironment env) { - this.env = env; - output = new HashMap>(); - } - - public void process() { - // XXX how does getSpecifiedTypeDeclarations differ? - for (TypeDeclaration decl : env.getTypeDeclarations()) { - analyze(decl); - for (MethodDeclaration m : decl.getMethods()) { - analyze(m); - } - for (FieldDeclaration f : decl.getFields()) { - analyze(f); - } - } - for (Map.Entry> outputEntry : output.entrySet()) { - String annName = outputEntry.getKey(); - try { - OutputStream os = env.getFiler().createBinaryFile(Filer.Location.CLASS_TREE, "", - new File("META-INF" + File.separator + "annotations" + File.separator + annName)); - try { - ObjectOutputStream oos = new ObjectOutputStream(os); - for (SerAnnotatedElement el : outputEntry.getValue()) { - oos.writeObject(el); - } - oos.writeObject(null); - oos.flush(); - } finally { - os.close(); - } - } catch (IOException x) { - env.getMessager().printError(x.toString()); - } - } - } - - private void analyze(Declaration decl) { - for (AnnotationMirror ann : decl.getAnnotationMirrors()) { - // First check to see if it is an @Indexable annotation. - boolean indexable = false; - TypeMirror objType = null; // upper type bound on annotated elements, or null for Object.class - for (AnnotationMirror metaAnn : ann.getAnnotationType().getDeclaration().getAnnotationMirrors()) { - if (getQualifiedNameUsingShell(metaAnn.getAnnotationType().getDeclaration()).equals(Indexable.class.getName())) { - // Yes it is. Now just find the type=... if there is one: - Map values = metaAnn.getElementValues(); - if (!values.isEmpty()) { - AnnotationValue val = values.values().iterator().next(); - objType = (TypeMirror) val.getValue(); - } - indexable = true; - break; - } - } - if (!indexable) { - continue; - } - // XXX check that it is not @Inherited, and that it has the right @Target - // XXX check that decl is public - // XXX check that decl is static if a method, etc. - // XXX check that decl is assignable to objType if that is not null - String annName = getQualifiedNameUsingShell(ann.getAnnotationType().getDeclaration()); - List existingOutput = output.get(annName); - if (existingOutput == null) { - existingOutput = new ArrayList(); - output.put(annName, existingOutput); - } - existingOutput.add(makeSerAnnotatedElement(decl, ann.getElementValues())); - } - } - - /** - * Similar to {@link TypeDeclaration#getQualifiedName} but uses p.O$I rather than p.O.I. - * In JDK 6 could use Elements.getBinaryName. - */ - static String getQualifiedNameUsingShell(TypeDeclaration decl) { - TypeDeclaration outer = decl.getDeclaringType(); - if (outer != null) { - return getQualifiedNameUsingShell(outer) + '$' + decl.getSimpleName(); - } else { - return decl.getQualifiedName(); - } - } - - private SerAnnotatedElement makeSerAnnotatedElement(Declaration decl, Map annvalues) { - String className, memberName; - boolean isMethod; - if (decl instanceof TypeDeclaration) { - className = getQualifiedNameUsingShell((TypeDeclaration) decl); - memberName = null; - isMethod = false; - } else if (decl instanceof MethodDeclaration) { - MethodDeclaration _decl = (MethodDeclaration) decl; - className = getQualifiedNameUsingShell(_decl.getDeclaringType()); - memberName = _decl.getSimpleName(); - isMethod = true; - } else { - FieldDeclaration _decl = (FieldDeclaration) decl; - className = getQualifiedNameUsingShell(_decl.getDeclaringType()); - memberName = _decl.getSimpleName(); - isMethod = false; - } - return new SerAnnotatedElement(className, memberName, isMethod, translate(annvalues)); - } - - private static TreeMap translate(Map annvalues) { - TreeMap values = new TreeMap(); - for (Map.Entry entry : annvalues.entrySet()) { - String key = entry.getKey().getSimpleName(); - AnnotationValue val = entry.getValue(); - values.put(key, translate(val.getValue())); - } - return values; - } - - private static Object translate(Object annval) { - if (annval instanceof Collection) { - @SuppressWarnings("unchecked") - Collection annvals = (Collection) annval; - List values = new ArrayList(annvals.size()); - for (AnnotationValue v : annvals) { - values.add(translate(v.getValue())); - } - return values; - } else if (annval instanceof TypeMirror) { - return new SerTypeConst(getQualifiedNameUsingShell(((DeclaredType) annval).getDeclaration())); - } else if (annval instanceof EnumConstantDeclaration) { - EnumConstantDeclaration ecd = (EnumConstantDeclaration) annval; - return new SerEnumConst(getQualifiedNameUsingShell(ecd.getDeclaringType()), ecd.getSimpleName()); - } else if (annval instanceof AnnotationMirror) { - AnnotationMirror am = (AnnotationMirror) annval; - return new SerAnnConst(getQualifiedNameUsingShell(am.getAnnotationType().getDeclaration()), - translate(am.getElementValues())); - } else { - return annval; - } - } - -} diff -Nru sezpoz-1.9/sezpoz/src/main/java/net/java/sezpoz/impl/Indexer6.java sezpoz-1.10/sezpoz/src/main/java/net/java/sezpoz/impl/Indexer6.java --- sezpoz-1.9/sezpoz/src/main/java/net/java/sezpoz/impl/Indexer6.java 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/sezpoz/src/main/java/net/java/sezpoz/impl/Indexer6.java 2015-03-31 21:06:50.000000000 +0000 @@ -15,8 +15,8 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is SezPoz. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 2006-2010 Sun - * Microsystems, Inc. All Rights Reserved. + * 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 @@ -70,10 +70,12 @@ import javax.tools.FileObject; import javax.tools.StandardLocation; import net.java.sezpoz.Indexable; +import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement; /** * Processor for indexable annotations. */ +@IgnoreJRERequirement @SupportedSourceVersion(SourceVersion.RELEASE_6) @SupportedAnnotationTypes("*") @SupportedOptions("sezpoz.quiet") @@ -85,6 +87,7 @@ @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { if (roundEnv.processingOver()) { + // TODO we should not write until processingOver return false; } for (Element indexable : roundEnv.getElementsAnnotatedWith(Indexable.class)) { diff -Nru sezpoz-1.9/sezpoz/src/main/java/net/java/sezpoz/impl/IndexerFactory.java sezpoz-1.10/sezpoz/src/main/java/net/java/sezpoz/impl/IndexerFactory.java --- sezpoz-1.9/sezpoz/src/main/java/net/java/sezpoz/impl/IndexerFactory.java 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/sezpoz/src/main/java/net/java/sezpoz/impl/IndexerFactory.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +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. Portions Copyright 2006-2010 Sun - * Microsystems, Inc. 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 com.sun.mirror.apt.AnnotationProcessor; -import com.sun.mirror.apt.AnnotationProcessorEnvironment; -import com.sun.mirror.apt.AnnotationProcessorFactory; -import com.sun.mirror.declaration.AnnotationTypeDeclaration; -import java.util.Collection; -import java.util.Collections; -import java.util.Set; - -/** - * Factory for the processor. - */ -public class IndexerFactory implements AnnotationProcessorFactory { - - public IndexerFactory() {} - - public Collection supportedOptions() { - return Collections.emptySet(); - } - - public Collection supportedAnnotationTypes() { - return Collections.singleton("*"); - } - - public AnnotationProcessor getProcessorFor(Set atds, AnnotationProcessorEnvironment env) { - return new Indexer5(atds, env); - } - -} diff -Nru sezpoz-1.9/sezpoz/src/main/java/net/java/sezpoz/impl/SerAnnConst.java sezpoz-1.10/sezpoz/src/main/java/net/java/sezpoz/impl/SerAnnConst.java --- sezpoz-1.9/sezpoz/src/main/java/net/java/sezpoz/impl/SerAnnConst.java 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/sezpoz/src/main/java/net/java/sezpoz/impl/SerAnnConst.java 2015-03-31 21:06:50.000000000 +0000 @@ -15,8 +15,8 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is SezPoz. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 2006-2010 Sun - * Microsystems, Inc. All Rights Reserved. + * 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 diff -Nru sezpoz-1.9/sezpoz/src/main/java/net/java/sezpoz/impl/SerAnnotatedElement.java sezpoz-1.10/sezpoz/src/main/java/net/java/sezpoz/impl/SerAnnotatedElement.java --- sezpoz-1.9/sezpoz/src/main/java/net/java/sezpoz/impl/SerAnnotatedElement.java 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/sezpoz/src/main/java/net/java/sezpoz/impl/SerAnnotatedElement.java 2015-03-31 21:06:50.000000000 +0000 @@ -15,8 +15,8 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is SezPoz. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 2006-2010 Sun - * Microsystems, Inc. All Rights Reserved. + * 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 diff -Nru sezpoz-1.9/sezpoz/src/main/java/net/java/sezpoz/impl/SerEnumConst.java sezpoz-1.10/sezpoz/src/main/java/net/java/sezpoz/impl/SerEnumConst.java --- sezpoz-1.9/sezpoz/src/main/java/net/java/sezpoz/impl/SerEnumConst.java 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/sezpoz/src/main/java/net/java/sezpoz/impl/SerEnumConst.java 2015-03-31 21:06:50.000000000 +0000 @@ -15,8 +15,8 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is SezPoz. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 2006-2010 Sun - * Microsystems, Inc. All Rights Reserved. + * 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 diff -Nru sezpoz-1.9/sezpoz/src/main/java/net/java/sezpoz/impl/SerTypeConst.java sezpoz-1.10/sezpoz/src/main/java/net/java/sezpoz/impl/SerTypeConst.java --- sezpoz-1.9/sezpoz/src/main/java/net/java/sezpoz/impl/SerTypeConst.java 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/sezpoz/src/main/java/net/java/sezpoz/impl/SerTypeConst.java 2015-03-31 21:06:50.000000000 +0000 @@ -15,8 +15,8 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is SezPoz. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 2006-2010 Sun - * Microsystems, Inc. All Rights Reserved. + * 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 diff -Nru sezpoz-1.9/sezpoz/src/main/java/net/java/sezpoz/Indexable.java sezpoz-1.10/sezpoz/src/main/java/net/java/sezpoz/Indexable.java --- sezpoz-1.9/sezpoz/src/main/java/net/java/sezpoz/Indexable.java 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/sezpoz/src/main/java/net/java/sezpoz/Indexable.java 2015-03-31 21:06:50.000000000 +0000 @@ -15,8 +15,8 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is SezPoz. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 2006-2010 Sun - * Microsystems, Inc. All Rights Reserved. + * 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 diff -Nru sezpoz-1.9/sezpoz/src/main/java/net/java/sezpoz/IndexError.java sezpoz-1.10/sezpoz/src/main/java/net/java/sezpoz/IndexError.java --- sezpoz-1.9/sezpoz/src/main/java/net/java/sezpoz/IndexError.java 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/sezpoz/src/main/java/net/java/sezpoz/IndexError.java 2015-03-31 21:06:50.000000000 +0000 @@ -15,8 +15,8 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is SezPoz. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 2006-2010 Sun - * Microsystems, Inc. All Rights Reserved. + * 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 diff -Nru sezpoz-1.9/sezpoz/src/main/java/net/java/sezpoz/IndexItem.java sezpoz-1.10/sezpoz/src/main/java/net/java/sezpoz/IndexItem.java --- sezpoz-1.9/sezpoz/src/main/java/net/java/sezpoz/IndexItem.java 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/sezpoz/src/main/java/net/java/sezpoz/IndexItem.java 2015-03-31 21:06:50.000000000 +0000 @@ -15,8 +15,8 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is SezPoz. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 2006-2010 Sun - * Microsystems, Inc. All Rights Reserved. + * 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 @@ -96,7 +96,7 @@ * @return a live or proxy annotation */ public A annotation() { - return proxy(annotationType, structure.values); + return proxy(loader, annotationType, structure.values); } /** @@ -215,10 +215,10 @@ return "@" + annotationType.getName() + ":" + structure; } - private static T proxy(Class type, Map data) { - return type.cast(Proxy.newProxyInstance(type.getClassLoader(), + private static T proxy(ClassLoader loader, Class type, Map data) { + return type.cast(Proxy.newProxyInstance(loader, new Class[] {type}, - new AnnotationProxy(type, data))); + new AnnotationProxy(loader, type, data))); } /** @@ -226,12 +226,15 @@ */ private static final class AnnotationProxy implements InvocationHandler { + /** class loader to use */ + private final ClassLoader loader; /** type of the annotation */ private final Class type; /** (non-default) annotation method values; value may be wrapped in Ser*Const objects or ArrayList */ private final Map data; - public AnnotationProxy(Class type, Map data) { + public AnnotationProxy(ClassLoader loader, Class type, Map data) { + this.loader = loader; this.type = type; this.data = data; } @@ -322,12 +325,12 @@ private Object evaluate(Object o, Class expectedType) throws Exception { if (o instanceof SerAnnConst) { SerAnnConst a = (SerAnnConst) o; - return proxy(type.getClassLoader().loadClass(a.name).asSubclass(Annotation.class), a.values); + return proxy(loader, loader.loadClass(a.name).asSubclass(Annotation.class), a.values); } else if (o instanceof SerTypeConst) { - return type.getClassLoader().loadClass(((SerTypeConst) o).name); + return loader.loadClass(((SerTypeConst) o).name); } else if (o instanceof SerEnumConst) { SerEnumConst e = (SerEnumConst) o; - return type.getClassLoader().loadClass(e.enumName).getField(e.constName).get(null); + return loader.loadClass(e.enumName).getField(e.constName).get(null); } else if (o instanceof ArrayList) { List l = (List) o; Class compType = expectedType.getComponentType(); diff -Nru sezpoz-1.9/sezpoz/src/main/java/net/java/sezpoz/Index.java sezpoz-1.10/sezpoz/src/main/java/net/java/sezpoz/Index.java --- sezpoz-1.9/sezpoz/src/main/java/net/java/sezpoz/Index.java 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/sezpoz/src/main/java/net/java/sezpoz/Index.java 2015-03-31 21:06:50.000000000 +0000 @@ -15,8 +15,8 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is SezPoz. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 2006-2010 Sun - * Microsystems, Inc. All Rights Reserved. + * 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 diff -Nru sezpoz-1.9/sezpoz/src/main/resources/META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory sezpoz-1.10/sezpoz/src/main/resources/META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory --- sezpoz-1.9/sezpoz/src/main/resources/META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/sezpoz/src/main/resources/META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -net.java.sezpoz.impl.IndexerFactory diff -Nru sezpoz-1.9/sezpoz/src/test/java/net/java/sezpoz/ClassLoaderTest.java sezpoz-1.10/sezpoz/src/test/java/net/java/sezpoz/ClassLoaderTest.java --- sezpoz-1.9/sezpoz/src/test/java/net/java/sezpoz/ClassLoaderTest.java 1970-01-01 00:00:00.000000000 +0000 +++ sezpoz-1.10/sezpoz/src/test/java/net/java/sezpoz/ClassLoaderTest.java 2015-03-31 21:06:50.000000000 +0000 @@ -0,0 +1,116 @@ +/* + * 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; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.lang.reflect.Method; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.Iterator; +import java.util.concurrent.Callable; + +import net.java.sezpoz.impl.TestUtils; + +import org.junit.Before; +import org.junit.Test; + +/** + * Check class loader issues. + * + * @author Johannes Schindelin + */ +public class ClassLoaderTest { + + private File dir, src1, clz1, src2, clz2; + private ClassLoader loader1, loader2; + @Before public void setUp() throws Exception { + dir = TestUtils.getWorkDir(this); + TestUtils.clearDir(dir); + src1 = new File(dir, "src1"); + clz1 = new File(dir, "clz1"); + clz1.mkdirs(); + loader1 = new URLClassLoader(new URL[] {clz1.toURI().toURL()}); + src2 = new File(dir, "src2"); + clz2 = new File(dir, "clz2"); + clz2.mkdirs(); + loader2 = new URLClassLoader(new URL[] {clz2.toURI().toURL()}, loader1); + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Test public void differentLoaders() throws Exception { + TestUtils.makeSource(src1, "api.MyAnnotation", + "import java.lang.annotation.ElementType;", + "import java.lang.annotation.Retention;", + "import java.lang.annotation.RetentionPolicy;", + "import java.lang.annotation.Target;", + "import java.util.concurrent.Callable;", + "import net.java.sezpoz.Indexable;", + "@Retention(RetentionPolicy.RUNTIME)", + "@Target(ElementType.TYPE)", + "@Indexable(type = Callable.class)", + "public @interface MyAnnotation {", + "Class myClass();", + "}"); + TestUtils.runApt(src1, null, clz1, new File[0], null); + + TestUtils.makeSource(src2, "com.example.MyExample", + "import api.MyAnnotation;", + "import java.util.concurrent.Callable;", + "@MyAnnotation(myClass = MyExample.class)", + "public class MyExample implements Callable {", + "public Object call() {", + "return \"Hello, World!\";", + "}", + "}"); + TestUtils.runApt(src2, null, clz2, new File[] {clz1}, null); + + final Class annotationClass = loader1.loadClass("api.MyAnnotation"); + final Class exampleClass = loader2.loadClass("com.example.MyExample"); + final Index index = Index.load(annotationClass, Callable.class, loader2); + + Iterator it = index.iterator(); + assertTrue(it.hasNext()); + IndexItem item = it.next(); + assertFalse(it.hasNext()); + + final Object annotation = item.annotation(); + final Method myClassMethod = annotation.getClass().getMethod("myClass"); + final Object myClass = myClassMethod.invoke(annotation); + assertEquals(myClass, exampleClass); + } + +} diff -Nru sezpoz-1.9/sezpoz/src/test/java/net/java/sezpoz/impl/AptFailedException.java sezpoz-1.10/sezpoz/src/test/java/net/java/sezpoz/impl/AptFailedException.java --- sezpoz-1.9/sezpoz/src/test/java/net/java/sezpoz/impl/AptFailedException.java 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/sezpoz/src/test/java/net/java/sezpoz/impl/AptFailedException.java 2015-03-31 21:06:50.000000000 +0000 @@ -15,8 +15,8 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is SezPoz. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 2006-2010 Sun - * Microsystems, Inc. All Rights Reserved. + * 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 diff -Nru sezpoz-1.9/sezpoz/src/test/java/net/java/sezpoz/impl/Indexer5Test.java sezpoz-1.10/sezpoz/src/test/java/net/java/sezpoz/impl/Indexer5Test.java --- sezpoz-1.9/sezpoz/src/test/java/net/java/sezpoz/impl/Indexer5Test.java 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/sezpoz/src/test/java/net/java/sezpoz/impl/Indexer5Test.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +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. Portions Copyright 2006-2010 Sun - * Microsystems, Inc. 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; - -/** - * Test for JDK 5 ("APT") version of indexer. - */ -public class Indexer5Test extends IndexerTestBase { - - protected boolean useJsr199() { - return false; - } - -} diff -Nru sezpoz-1.9/sezpoz/src/test/java/net/java/sezpoz/impl/Indexer6Test.java sezpoz-1.10/sezpoz/src/test/java/net/java/sezpoz/impl/Indexer6Test.java --- sezpoz-1.9/sezpoz/src/test/java/net/java/sezpoz/impl/Indexer6Test.java 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/sezpoz/src/test/java/net/java/sezpoz/impl/Indexer6Test.java 2015-03-31 21:06:50.000000000 +0000 @@ -15,8 +15,8 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is SezPoz. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 2006-2010 Sun - * Microsystems, Inc. All Rights Reserved. + * 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 @@ -45,10 +45,6 @@ */ public class Indexer6Test extends IndexerTestBase { - protected boolean useJsr199() { - return true; - } - @Test public void incrementalCompilation() throws Exception { File src1 = new File(dir, "src1"); TestUtils.makeSource(src1, "Thing", @@ -60,20 +56,20 @@ "String name();", "}"); File clz1 = new File(dir, "clz1"); - TestUtils.runApt(src1, null, clz1, null, null, useJsr199()); + 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, useJsr199()); + 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, useJsr199()); + TestUtils.runApt(src2, "Impl2", clz2, new File[] {clz1}, null); assertEquals(Collections.singletonMap("Thing", new TreeSet(Arrays.asList( "Impl1{name=one}", "Impl2{name=two}" @@ -91,26 +87,26 @@ "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, useJsr199()); - TestUtils.runAptExpectingErrors(src, "A|C2", clz, null, "public", useJsr199()); + 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, useJsr199()); - TestUtils.runAptExpectingErrors(src, "A|M2", clz, null, "public", useJsr199()); - TestUtils.runAptExpectingErrors(src, "A|M3", clz, null, "public", useJsr199()); - TestUtils.runAptExpectingErrors(src, "A|M4", clz, null, "public", useJsr199()); - TestUtils.runAptExpectingErrors(src, "A|M5", clz, null, "public", useJsr199()); + 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, useJsr199()); - TestUtils.runAptExpectingErrors(src, "A|F2", clz, null, "public", useJsr199()); - TestUtils.runAptExpectingErrors(src, "A|F3", clz, null, "public", useJsr199()); - TestUtils.runAptExpectingErrors(src, "A|F4", clz, null, "public", useJsr199()); + 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 { @@ -124,26 +120,26 @@ 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, useJsr199()); - TestUtils.runAptExpectingErrors(src, "A|C2", clz, null, "abstract", useJsr199()); - TestUtils.runAptExpectingErrors(src, "A|C3", clz, null, "constructor", useJsr199()); - TestUtils.runAptExpectingErrors(src, "A|C4", clz, null, "constructor", useJsr199()); + 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, useJsr199()); - TestUtils.runAptExpectingErrors(src, "A|M2", clz, null, "static", useJsr199()); - TestUtils.runAptExpectingErrors(src, "A|M3", clz, null, "parameters", useJsr199()); + 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, useJsr199()); - TestUtils.runAptExpectingErrors(src, "A|F2", clz, null, "static", useJsr199()); - TestUtils.runAptExpectingErrors(src, "A|F3", clz, null, "final", useJsr199()); + 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, useJsr199()); - TestUtils.runAptExpectingErrors(src, "A|N2", clz, null, "static", useJsr199()); + 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()); @@ -159,20 +155,20 @@ "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, useJsr199()); - TestUtils.runAptExpectingErrors(src, "A|C2", clz, null, "Runnable", useJsr199()); + 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, useJsr199()); - TestUtils.runAptExpectingErrors(src, "A|M2", clz, null, "Runnable", useJsr199()); - TestUtils.runApt(src, "A|M3", clz, null, null, useJsr199()); + 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, useJsr199()); - TestUtils.runAptExpectingErrors(src, "A|F2", clz, null, "Runnable", useJsr199()); - TestUtils.runApt(src, "A|F3", clz, null, null, useJsr199()); + 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 { @@ -182,7 +178,7 @@ "@Retention(RetentionPolicy.SOURCE)", "@net.java.sezpoz.Indexable", "public @interface A1 {}"); - TestUtils.runApt(src, "A1", clz, null, null, useJsr199()); + TestUtils.runApt(src, "A1", clz, null, null); TestUtils.makeSource(src, "x.A2", "import java.lang.annotation.*;", "@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})", @@ -190,33 +186,33 @@ "@Inherited", "@net.java.sezpoz.Indexable", "public @interface A2 {}"); - TestUtils.runAptExpectingErrors(src, "A2", clz, null, "@Inherited", useJsr199()); + 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", useJsr199()); + 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", useJsr199()); + 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", useJsr199()); + 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, useJsr199()); + TestUtils.runApt(src, "A6", clz, null, baos); baos.flush(); assertTrue("output warns about @Retention: " + baos, baos.toString().contains("@Retention")); } diff -Nru sezpoz-1.9/sezpoz/src/test/java/net/java/sezpoz/impl/IndexerTestBase.java sezpoz-1.10/sezpoz/src/test/java/net/java/sezpoz/impl/IndexerTestBase.java --- sezpoz-1.9/sezpoz/src/test/java/net/java/sezpoz/impl/IndexerTestBase.java 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/sezpoz/src/test/java/net/java/sezpoz/impl/IndexerTestBase.java 2015-03-31 21:06:50.000000000 +0000 @@ -15,8 +15,8 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is SezPoz. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 2006-2010 Sun - * Microsystems, Inc. All Rights Reserved. + * 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 @@ -48,8 +48,6 @@ */ public abstract class IndexerTestBase { - protected abstract boolean useJsr199(); - protected File dir, src, clz; @Before public void setUp() throws Exception { dir = TestUtils.getWorkDir(this); @@ -71,7 +69,7 @@ "String iconPath() default \"\";", "}"); File clz1 = new File(dir, "clz1"); - TestUtils.runApt(src1, null, clz1, null, null, useJsr199()); + TestUtils.runApt(src1, null, clz1, null, null); File src2 = new File(dir, "src2"); TestUtils.makeSource(src2, "impl.PrintAction", "@api.MenuItem(menuName=\"File\", itemName=\"Print\", iconPath=\".../print.png\")", @@ -80,7 +78,7 @@ "public void actionPerformed(java.awt.event.ActionEvent e) {}", "}"); File clz2 = new File(dir, "clz2"); - TestUtils.runApt(src2, null, clz2, new File[] {clz1}, null, useJsr199()); + TestUtils.runApt(src2, null, clz2, new File[] {clz1}, null); assertEquals(Collections.singletonMap("api.MenuItem", Collections.singleton( "impl.PrintAction{iconPath=.../print.png, itemName=Print, menuName=File}" )), TestUtils.findMetadata(clz2)); @@ -98,7 +96,7 @@ TestUtils.makeSource(src, "y.C", "@x.A(x=\"foo\\\\\\\"\\n\")", "public class C {}"); - TestUtils.runApt(src, null, clz, null, null, useJsr199()); + TestUtils.runApt(src, null, clz, null, null); assertEquals(Collections.singletonMap("x.A", Collections.singleton( "y.C{x=foo\\\"\n}" )), TestUtils.findMetadata(clz)); @@ -126,7 +124,7 @@ "import x.*;", "@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, useJsr199()); + TestUtils.runApt(src, null, clz, null, null); assertEquals(Collections.singletonMap("x.A", Collections.singleton( "y.C{b=true, c=x, i=3, other=@x.Other{v=1}, others=[@x.Other{v=2}]}" )), TestUtils.findMetadata(clz)); @@ -165,7 +163,7 @@ "import x.*;", "@B(as={@A, @A(), @A(i=20)})", "public class C5 {}"); - TestUtils.runApt(src, null, clz, null, null, useJsr199()); + TestUtils.runApt(src, null, clz, null, null); Map> expected = new HashMap>(); expected.put("x.A", new TreeSet(Arrays.asList(new String[] { "y.C1{i=33}", @@ -195,7 +193,7 @@ "import x.*;", "@A(clazz=String.class,enoom={E.ONE,E.TWO})", "public class C {}"); - TestUtils.runApt(src, null, clz, null, null, useJsr199()); + TestUtils.runApt(src, null, clz, null, null); assertEquals(Collections.singletonMap("x.A", Collections.singleton( "y.C{clazz=java.lang.String, enoom=[ONE, TWO]}" )), TestUtils.findMetadata(clz)); @@ -218,7 +216,7 @@ "@A(b=false)", "public static Object m() {return null;}", "}"); - TestUtils.runApt(src, null, clz, null, null, useJsr199()); + TestUtils.runApt(src, null, clz, null, null); assertEquals(Collections.singletonMap("x.A", new TreeSet(Arrays.asList(new String[] { "y.C#F{b=true}", "y.C#m(){b=false}", @@ -242,7 +240,7 @@ "@x.Outer.A(type=T.class)", "public static class C {}", "}"); - TestUtils.runApt(src, null, clz, null, null, useJsr199()); + TestUtils.runApt(src, null, clz, null, null); assertEquals(Collections.singletonMap("x.Outer$A", Collections.singleton( "y.Auter$C{type=y.Auter$T}" )), TestUtils.findMetadata(clz)); diff -Nru sezpoz-1.9/sezpoz/src/test/java/net/java/sezpoz/impl/TestUtils.java sezpoz-1.10/sezpoz/src/test/java/net/java/sezpoz/impl/TestUtils.java --- sezpoz-1.9/sezpoz/src/test/java/net/java/sezpoz/impl/TestUtils.java 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/sezpoz/src/test/java/net/java/sezpoz/impl/TestUtils.java 2015-03-31 21:06:50.000000000 +0000 @@ -15,8 +15,8 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is SezPoz. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 2006-2010 Sun - * Microsystems, Inc. All Rights Reserved. + * 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 @@ -93,20 +93,18 @@ } /** - * Run the apt tool. + * Run annotation processing. * @param src a source root (runs apt on all *.java it finds) * @param srcIncludes optional regex to limit class names to compile * @param dest a dest dir (also compiles classes there) * @param cp classpath entries for processor (Indexable will always be accessible), or null * @param stderr output stream to use, or null for test console - * @param jsr199 whether to use JSR 199 (i.e. JDK 6 javac) annotation processing - * @throws AptFailedException if processing failed * @throws Exception if something unexpected went wrong */ - public static void runApt(File src, String srcIncludes, File dest, File[] cp, OutputStream stderr, boolean jsr199) throws Exception { + public static void runApt(File src, String srcIncludes, File dest, File[] cp, OutputStream stderr) throws Exception { List args = new ArrayList(); String indexableLoc = new File(URI.create(Indexable.class.getProtectionDomain().getCodeSource().getLocation().toExternalForm())).getAbsolutePath(); - args.add(jsr199 ? "-processorpath" : "-factorypath"); + args.add("-processorpath"); args.add(indexableLoc); args.add("-classpath"); StringBuffer b = new StringBuffer(indexableLoc); @@ -122,18 +120,9 @@ dest.mkdirs(); args.add("-Asezpoz.quiet=true"); scan(args, src, srcIncludes); - if (!jsr199) { - args.add("-proc:none"); - } //System.err.println("running apt with args: " + args); String[] argsA = args.toArray(new String[args.size()]); - int res; - if (jsr199) { - res = ToolProvider.getSystemJavaCompiler().run(null, null, stderr, argsA); - //res = com.sun.tools.javac.Main.compile(argsA, stderr); - } else { - res = com.sun.tools.apt.Main.process(new PrintWriter(stderr != null ? stderr : System.err), argsA); - } + int res = ToolProvider.getSystemJavaCompiler().run(null, null, stderr, argsA); if (res != 0) { throw new AptFailedException(res); } @@ -149,19 +138,18 @@ } /** - * Run the apt tool and expect an error to be issued. + * Run annotation processing and expect an error to be issued. * @param src a source root (runs apt on all *.java it finds) * @param srcIncludes optional regex to limit class names to compile * @param dest a dest dir (also compiles classes there) * @param cp classpath entries for processor (Indexable will always be accessible), or null * @param error an error you expect to see printed (APT must also fail), else assertion failure - * @param jsr199 whether to use JSR 199 (i.e. JDK 6 javac) annotation processing * @throws Exception if something unexpected went wrong */ - public static void runAptExpectingErrors(File src, String srcIncludes, File dest, File[] cp, String error, boolean jsr199) throws Exception { + public static void runAptExpectingErrors(File src, String srcIncludes, File dest, File[] cp, String error) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { - runApt(src, srcIncludes, dest, cp, baos, jsr199); + runApt(src, srcIncludes, dest, cp, baos); Assert.fail("annotation processing should have failed"); } catch (AptFailedException x) { String log = baos.toString(); diff -Nru sezpoz-1.9/sezpoz/src/test/java/net/java/sezpoz/IndexTest.java sezpoz-1.10/sezpoz/src/test/java/net/java/sezpoz/IndexTest.java --- sezpoz-1.9/sezpoz/src/test/java/net/java/sezpoz/IndexTest.java 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/sezpoz/src/test/java/net/java/sezpoz/IndexTest.java 2015-03-31 21:06:50.000000000 +0000 @@ -15,8 +15,8 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is SezPoz. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 2006-2010 Sun - * Microsystems, Inc. All Rights Reserved. + * 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 @@ -91,7 +91,7 @@ "public class PrintAction extends javax.swing.AbstractAction {", "public void actionPerformed(java.awt.event.ActionEvent e) {}", "}"); - TestUtils.runApt(src, null, clz, new File[0], null, false); + TestUtils.runApt(src, null, clz, new File[0], null); Class menuItemClazz = loader.loadClass("api.MenuItem"); Index index = Index.load(menuItemClazz, Action.class, loader); Iterator it = index.iterator(); @@ -146,7 +146,7 @@ "public class C {}"); TestUtils.runApt(src, null, clz, new File[] { new File(URI.create(Marker.class.getProtectionDomain().getCodeSource().getLocation().toExternalForm())) - }, null, false); + }, null); int cnt = 0; for (IndexItem item : Index.load(Marker.class, Object.class, loader)) { cnt++; @@ -179,7 +179,7 @@ "@x.A", "public static Object m() {return 2;}", "}"); - TestUtils.runApt(src, null, clz, new File[0], null, false); + TestUtils.runApt(src, null, clz, new File[0], null); Class a = loader.loadClass("x.A").asSubclass(Annotation.class); int cnt = 0; for (IndexItem item : Index.load(a, Object.class, loader)) { @@ -206,14 +206,14 @@ TestUtils.makeSource(src, "y.C1", "@x.A", "public class C1 {}"); - TestUtils.runApt(src, null, clz, new File[0], null, false); + TestUtils.runApt(src, null, clz, new File[0], null); File src2 = new File(dir, "src2"); TestUtils.makeSource(src2, "z.C2", "@x.A", "public class C2 {}"); File clz2 = new File(dir, "clz2"); clz2.mkdirs(); - TestUtils.runApt(src2, null, clz2, new File[] {clz}, null, false); + TestUtils.runApt(src2, null, clz2, new File[] {clz}, null); loader = new URLClassLoader(new URL[] {clz.toURI().toURL(), clz2.toURI().toURL()}); Class a = loader.loadClass("x.A").asSubclass(Annotation.class); Iterator it = Index.load(a, Object.class, loader).iterator(); @@ -241,14 +241,14 @@ TestUtils.makeSource(src, "y.C1", "@x.A(x=1)", "public class C1 {}"); - TestUtils.runApt(src, null, clz, new File[0], null, false); + TestUtils.runApt(src, null, clz, new File[0], null); File src2 = new File(dir, "src2"); TestUtils.makeSource(src2, "y.C1", "@x.A(x=2)", "public class C1 {}"); File clz2 = new File(dir, "clz2"); clz2.mkdirs(); - TestUtils.runApt(src2, null, clz2, new File[] {clz}, null, false); + TestUtils.runApt(src2, null, clz2, new File[] {clz}, null); loader = new URLClassLoader(new URL[] {clz.toURI().toURL(), clz2.toURI().toURL()}); Class a = loader.loadClass("x.A").asSubclass(Annotation.class); Iterator it = Index.load(a, Object.class, loader).iterator(); @@ -274,7 +274,7 @@ TestUtils.makeSource(src, "y.C1", "@x.A(x=1)", "public class C1 {}"); - TestUtils.runApt(src, null, clz, new File[0], null, false); + TestUtils.runApt(src, null, clz, new File[0], null); URL[] urls = new URL[9]; // too slow to make this really big for (int i = 0; i < urls.length; i++) { urls[i] = new URL(new URL("http://" + i + ".nowhere.net/"), "", new URLStreamHandler() { @@ -311,13 +311,13 @@ "import x.A;", "public class C {", "@A", - "public static void m1() {}", + "public static Void m1() {return null;}", "@A(x=5)", - "public static void m2() {}", + "public static Void m2() {return null;}", "@A(x=17)", - "public static void m3() {}", + "public static Void m3() {return null;}", "}"); - TestUtils.runApt(src, null, clz, new File[0], null, false); + TestUtils.runApt(src, null, clz, new File[0], null); Class a = loader.loadClass("x.A").asSubclass(Annotation.class); int cnt = 0; Annotation[] proxyAnns = new Annotation[3]; @@ -395,7 +395,7 @@ "c=A.Nested.class", ")", "public class C {}"); - TestUtils.runApt(src, null, clz, new File[0], null, false); + TestUtils.runApt(src, null, clz, new File[0], null); Class a = loader.loadClass("x.A").asSubclass(Annotation.class); IndexItem item = Index.load(a, Object.class, loader).iterator().next(); Class b = loader.loadClass("x.B"); diff -Nru sezpoz-1.9/www/alm-process/snippets/page.xml sezpoz-1.10/www/alm-process/snippets/page.xml --- sezpoz-1.9/www/alm-process/snippets/page.xml 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/www/alm-process/snippets/page.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ - -index.htmlSubprojects diff -Nru sezpoz-1.9/www/index.html sezpoz-1.10/www/index.html --- sezpoz-1.9/www/index.html 2011-06-03 13:22:00.000000000 +0000 +++ sezpoz-1.10/www/index.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,186 +0,0 @@ - - -SezPoz - - - - -

Introduction

-

-SezPoz is a lightweight and easy-to-learn library that lets you perform modular service lookups. -It provides some of the same capabilities as (for example) java.util.ServiceLoader, -Eclipse extension points, and NetBeans Lookup and XML layers. -However, SezPoz has some special advantages: -

-
    -
  1. -

    - The service registrations are made just using type-checked Java annotations. - There are no configuration files to edit, and your Java IDE can show you registrations since they are simply usages of an annotation. - On JDK 6 (or later), no special build or packaging steps are required (just javac); on JDK 5, you just need to run APT (with default arguments), - instead of or in addition to javac for any sources which may contain indexable items. - Looking up services just requires that you have a ClassLoader which can "see" all of the "modules" (as with ServiceLoader). -

    -
  2. -
  3. -

    - You can register individual objects (values of static fields or methods) instead of whole classes. -

    -
  4. -
  5. -

    - You can associate static metadata with each implementation, using regular annotation values. - The caller can choose to inspect the metadata without loading the actual implementation object (as with Eclipse extension points). -

    -
  6. -
-

-(Why the name? SezPoz "says" the "position" of your services. It is also a -"seznam -poznámek".) -

- -

Sources and Binaries

-

-Sources are in the form of Maven projects. To build: -

-
-mvn install
-
-

-To try the demo application: -

-
-mvn -f demo/app/pom.xml exec:exec
-
-

-Binaries, sources, and Javadoc can all be downloaded from the -Maven repository. -

-

-For usage from Maven applications, add the java.net repository -(details) -and use the artifact net.java.sezpoz:sezpoz, for example: -

-
-<repositories>
-  <repository>
-    <id>java.net</id>
-    <name>java.net</name>
-    <url>http://download.java.net/maven/2/</url>
-  </repository>
-</repositories>
-<dependencies>
-  <dependency>
-    <groupId>net.java.sezpoz</groupId>
-    <artifactId>sezpoz</artifactId>
-    <version>(...latest available...)</version>
-  </dependency>
-</dependencies>
-
- -

Usage Summary

-

-See Javadoc for details on particular classes, or just look at -demo sources. -

- -Support for declaring, creating, and inspecting indices of annotated Java elements. -

- For example, to permit registration of simple menu items, while - making it possible to prepare a menu without loading any of them - until they are actually selected: -

- @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
- @Retention(RetentionPolicy.SOURCE)
- @Indexable(type=ActionListener.class)
- public @interface MenuItem {
-     String menuName();
-     String itemName();
-     String iconPath() default "";
- }
- 
- A concrete registration might look like: -
- @MenuItem(menuName="File", itemName="Print", iconPath=".../print.png")
- public class PrintAction extends AbstractAction {
-     public void actionPerformed(ActionEvent e) {...}
- }
- 
- Alternatively: -
- public class Actions {
-     @MenuItem(menuName="File", itemName="Print")
-     public static Action print() {...}
- }
- 
- or even: -
- public class Actions {
-     @MenuItem(menuName="File", itemName="Print")
-     public static final Action PRINT = ...;
- }
- 
- To create the index on JDK 6, just compile your sources normally with javac. - If using JDK 5, simply run apt instead of/in addition to javac. - (The processor is in the same JAR as this API and should be autodetected.) -

- Usage is then simple: -

- for (final IndexItem<MenuItem,ActionListener> item :
-         Index.load(MenuItem.class, ActionListener.class)) {
-     JMenu menu = new JMenu(item.annotation().menuName());
-     JMenuItem menuitem = new JMenuItem(item.annotation().itemName());
-     String icon = item.annotation().iconPath();
-     if (!icon.equals("")) {
-          menuitem.setIcon(new ImageIcon(icon));
-     }
-     menuitem.addActionListener(new ActionListener() {
-         public void actionPerformed(ActionEvent e) {
-             try {
-                 item.instance().actionPerformed(e);
-             } catch (InstantiationException x) {
-                 x.printStackTrace();
-             }
-         }
-     });
- }
- 
- -

Notes

-

-Known limitations: -

-
    -
  1. When using JDK 5 and apt, incremental compilation can result in an index file being generated with only some -of the desired entries, if other source files are omitted e.g. by Ant. -

    -This scenario works better using JDK 6's javac: if you compile just some sources which are marked with an indexable annotation, -these entries will be appended to any existing registrations from previous runs of the compiler. -(You should run a clean build if you delete annotations from sources.) -

  2. -
  3. The Java language spec currently prohibits recursive annotation definitions, -although javac in JDK 5 does not. (JDK 6 and 7's javac do.) -See bug #6264216.

  4. -
- -

-Eclipse-specific notes: make sure annotation processing is enabled at least for any -projects registering objects using annotations. Make sure the SezPoz library is -in the factory path for annotation processors. You also need to check the box -Run this container's processor in batch mode from the Advanced -button in Java Compiler > Annotation Processing > Factory Path. -There does not appear to be any way for Eclipse to discover processors -in the regular classpath as JSR 269 suggests, and there does not appear to be -any way to make these settings apply automatically to all projects. -Eclipse users are recommended to use javac (e.g. via Maven) to build. -Eclipse Help Page -Eclipse bug #280542 -

- - - - - - -