changeset 22512:1852abfbaca3

removed use of intermediate jvmci.options/ directory to create OptionDescriptors service files
author Doug Simon <doug.simon@oracle.com>
date Thu, 03 Sep 2015 17:03:51 +0200
parents df5a7841f92a
children 82818d115a98
files jvmci/jdk.internal.jvmci.options.processor/src/jdk/internal/jvmci/options/processor/OptionProcessor.java make/jvmci.make mx.jvmci/mx_jvmci.py mx.jvmci/mx_jvmci_makefile.py
diffstat 4 files changed, 10 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/jvmci/jdk.internal.jvmci.options.processor/src/jdk/internal/jvmci/options/processor/OptionProcessor.java	Thu Sep 03 14:47:36 2015 +0200
+++ b/jvmci/jdk.internal.jvmci.options.processor/src/jdk/internal/jvmci/options/processor/OptionProcessor.java	Thu Sep 03 17:03:51 2015 +0200
@@ -239,19 +239,6 @@
             }
             out.println("}");
         }
-
-        try {
-            createOptionsFile(pkg, topDeclaringClass.toString(), originatingElements);
-        } catch (IOException e) {
-            processingEnv.getMessager().printMessage(Kind.ERROR, e.getMessage(), info.topDeclaringType);
-        }
-    }
-
-    private void createOptionsFile(String pkg, String relativeName, Element... originatingElements) throws IOException {
-        String filename = "META-INF/jvmci.options/" + pkg + "." + relativeName;
-        FileObject file = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", filename, originatingElements);
-        PrintWriter writer = new PrintWriter(new OutputStreamWriter(file.openOutputStream(), "UTF-8"));
-        writer.close();
     }
 
     protected PrintWriter createSourceFile(String pkg, String relativeName, Filer filer, Element... originatingElements) {
--- a/make/jvmci.make	Thu Sep 03 14:47:36 2015 +0200
+++ b/make/jvmci.make	Thu Sep 03 17:03:51 2015 +0200
@@ -44,16 +44,15 @@
     $(QUIETLY) test ! -f $(vmconfig) || (mkdir -p $(vmconfigDest) && cp $(vmconfig) $(vmconfigDest))
 endef
 
-# Reads the files in jvmci.options/ created by OptionProcessor (the processor for the @Option annotation)
-# and appends to services/jdk.internal.jvmci.options.Options entries for the providers
-# also created by the same processor.
+# Finds the *_OptionsDescriptors classes created by OptionProcessor (the processor for the @Option annotation)
+# and appends their names to services/jdk.internal.jvmci.options.OptionDescriptors.
 # Arguments:
 #  1: directory with contents of the JAR file
 define process_options
-    $(eval options := $(1)/$(OPTIONS_INF))
     $(eval services := $(1)/META-INF/services)
     $(QUIETLY) test -d $(services) || mkdir -p $(services)
-    $(QUIETLY) test ! -d $(options) || (cd $(options) && for i in $$(ls); do echo $${i}_OptionDescriptors >> $(abspath $(services))/jdk.internal.jvmci.options.Options; done)
+    $(eval optionDescriptors := $(1)/META-INF/services/jdk.internal.jvmci.options.OptionDescriptors)
+    $(QUIETLY) cd $(1) && for i in $$(find . -name '*_OptionDescriptors.class' 2>/dev/null); do echo $${i} | sed 's:\./\(.*\)\.class:\1:g' | tr '/' '.' >> $(abspath $(optionDescriptors)); done
 endef
 
 # Extracts META-INF/jvmci.services from a JAR file into a given directory
--- a/mx.jvmci/mx_jvmci.py	Thu Sep 03 14:47:36 2015 +0200
+++ b/mx.jvmci/mx_jvmci.py	Thu Sep 03 17:03:51 2015 +0200
@@ -1694,7 +1694,6 @@
     def __opened__(self, arc, srcArc, services):
         self.services = services
         self.arc = arc
-        self.expectedOptionsProviders = set()
 
     def __add__(self, arcname, contents):
         if arcname.startswith('META-INF/jvmci.services/'):
@@ -1706,13 +1705,11 @@
             for service in contents.split(os.linesep):
                 self.jvmciServices.setdefault(service, []).append(provider)
             return True
-        elif arcname.startswith('META-INF/jvmci.options/'):
+        elif arcname.endswith('_OptionDescriptors.class'):
             # Need to create service files for the providers of the
             # jdk.internal.jvmci.options.Options service created by
             # jdk.internal.jvmci.options.processor.OptionProcessor.
-            optionsOwner = arcname[len('META-INF/jvmci.options/'):]
-            provider = optionsOwner + '_OptionDescriptors'
-            self.expectedOptionsProviders.add(provider.replace('.', '/') + '.class')
+            provider = arcname[:-len('.class'):].replace('/', '.')
             self.services.setdefault('jdk.internal.jvmci.options.OptionDescriptors', []).append(provider)
         return False
 
@@ -1720,8 +1717,6 @@
         return False
 
     def __closing__(self):
-        self.expectedOptionsProviders -= set(self.arc.zf.namelist())
-        assert len(self.expectedOptionsProviders) == 0, 'missing generated Options providers:\n  ' + '\n  '.join(self.expectedOptionsProviders)
         for service, providers in self.jvmciServices.iteritems():
             arcname = 'META-INF/jvmci.services/' + service
             # Convert providers to a set before printing to remove duplicates
--- a/mx.jvmci/mx_jvmci_makefile.py	Thu Sep 03 14:47:36 2015 +0200
+++ b/mx.jvmci/mx_jvmci_makefile.py	Thu Sep 03 17:03:51 2015 +0200
@@ -193,16 +193,15 @@
     $(QUIETLY) test ! -f $(vmconfig) || (mkdir -p $(vmconfigDest) && cp $(vmconfig) $(vmconfigDest))
 endef
 
-# Reads the files in jvmci.options/ created by OptionProcessor (the processor for the @Option annotation)
-# and appends to services/jdk.internal.jvmci.options.Options entries for the providers
-# also created by the same processor.
+# Finds the *_OptionsDescriptors classes created by OptionProcessor (the processor for the @Option annotation)
+# and appends their names to services/jdk.internal.jvmci.options.OptionDescriptors.
 # Arguments:
 #  1: directory with contents of the JAR file
 define process_options
-    $(eval options := $(1)/$(OPTIONS_INF))
     $(eval services := $(1)/META-INF/services)
     $(QUIETLY) test -d $(services) || mkdir -p $(services)
-    $(QUIETLY) test ! -d $(options) || (cd $(options) && for i in $$(ls); do echo $${i}_OptionDescriptors >> $(abspath $(services))/jdk.internal.jvmci.options.Options; done)
+    $(eval optionDescriptors := $(1)/META-INF/services/jdk.internal.jvmci.options.OptionDescriptors)
+    $(QUIETLY) cd $(1) && for i in $$(find . -name '*_OptionDescriptors.class' 2>/dev/null); do echo $${i} | sed 's:\\./\\(.*\\)\\.class:\\1:g' | tr '/' '.' >> $(abspath $(optionDescriptors)); done
 endef
 
 # Extracts META-INF/jvmci.services from a JAR file into a given directory