master moved from ba5acdf7cf1e to 338213332308

3 new revisions:

Revision: a9228269b4d6
Author:   Christian Edward Gruber <[email protected]>
Date:     Wed Nov 13 07:06:04 2013 UTC
Log: Make named classes for anonymous Modules so they appear prettier (and ...
http://code.google.com/p/google-guice/source/detail?r=a9228269b4d6

Revision: e1197a962b65
Author:   Christian Edward Gruber <[email protected]>
Date:     Wed Nov 13 07:06:31 2013 UTC
Log: Update Guice's maven build system to run the unit tests in three confi...
http://code.google.com/p/google-guice/source/detail?r=e1197a962b65

Revision: 338213332308
Author:   Christian Edward Gruber <[email protected]>
Date:     Wed Nov 13 07:07:22 2013 UTC
Log:      Make guice build with javac 8....
http://code.google.com/p/google-guice/source/detail?r=338213332308

==============================================================================
Revision: a9228269b4d6
Author:   Christian Edward Gruber <[email protected]>
Date:     Wed Nov 13 07:06:04 2013 UTC
Log: Make named classes for anonymous Modules so they appear prettier (and useful) in error messages.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=54796862

http://code.google.com/p/google-guice/source/detail?r=a9228269b4d6

Modified:
 /core/src/com/google/inject/util/Modules.java
 /core/test/com/google/inject/ModulesTest.java

=======================================
--- /core/src/com/google/inject/util/Modules.java Sat Oct 5 21:04:53 2013 UTC +++ /core/src/com/google/inject/util/Modules.java Wed Nov 13 07:06:04 2013 UTC
@@ -52,10 +52,11 @@
  */
 public final class Modules {
   private Modules() {}
-
-  public static final Module EMPTY_MODULE = new Module() {
+
+  public static final Module EMPTY_MODULE = new EmptyModule();
+  private static class EmptyModule implements Module {
     public void configure(Binder binder) {}
-  };
+  }

   /**
* Returns a builder that creates a module that overlays override modules over the given
@@ -108,15 +109,22 @@
    * Returns a new module that installs all of {@code modules}.
    */
   public static Module combine(Iterable<? extends Module> modules) {
-    final Set<Module> modulesSet = ImmutableSet.copyOf(modules);
-    return new Module() {
-      public void configure(Binder binder) {
-        binder = binder.skipSources(getClass());
-        for (Module module : modulesSet) {
-          binder.install(module);
-        }
+    return new CombinedModule(modules);
+  }
+
+  private static class CombinedModule implements Module {
+    final Set<Module> modulesSet;
+
+    CombinedModule(Iterable<? extends Module> modules) {
+      this.modulesSet = ImmutableSet.copyOf(modules);
+    }
+
+    public void configure(Binder binder) {
+      binder = binder.skipSources(getClass());
+      for (Module module : modulesSet) {
+        binder.install(module);
       }
-    };
+    }
   }

   /**
=======================================
--- /core/test/com/google/inject/ModulesTest.java Wed Sep 18 17:56:54 2013 UTC +++ /core/test/com/google/inject/ModulesTest.java Wed Nov 13 07:06:04 2013 UTC
@@ -49,18 +49,21 @@
* The module returned by Modules.combine shouldn't show up in binder sources.
    */
   public void testCombineSources() {
+    final Module m1 = newModule(1);
+    final Module m2 = newModule(2L);
+    final Module combined1 = Modules.combine(m1, m2);
     Module skipSourcesModule = new AbstractModule() {
       @Override protected void configure() {
-        install(Modules.combine(newModule(1), newModule(2L)));
+        install(combined1);
       }
     };
- Injector injector = Guice.createInjector(Modules.combine(skipSourcesModule));
+    final Module combined2 = Modules.combine(skipSourcesModule);
+    Injector injector = Guice.createInjector(combined2);
ElementSource source = (ElementSource) injector.getBinding(Integer.class).getSource();
-    // Check modules stack
     assertEquals(source.getModuleClassNames().size(), 4);
-    assertEquals(ImmutableList.of("com.google.inject.ModulesTest$2",
-        "com.google.inject.util.Modules$2", "com.google.inject.ModulesTest$1",
-        "com.google.inject.util.Modules$2"), source.getModuleClassNames());
+    assertEquals(ImmutableList.of(m1.getClass().getName(),
+ combined1.getClass().getName(), skipSourcesModule.getClass().getName(),
+        combined2.getClass().getName()), source.getModuleClassNames());
StackTraceElement stackTraceElement = (StackTraceElement) source.getDeclaringSource(); assertEquals(skipSourcesModule.getClass().getName(), stackTraceElement.getClassName());
   }

==============================================================================
Revision: e1197a962b65
Author:   Christian Edward Gruber <[email protected]>
Date:     Wed Nov 13 07:06:31 2013 UTC
Log: Update Guice's maven build system to run the unit tests in three configurations, representing the three different values for stack-trace inclusion in error messages. Additionally, modify the open-source InternalFlags to log a warning if a value is passed to the flag that does not correspond to the Enum.

Tested:
normal open-source tests in google's internal build
full maven build from MOE's assembly of the open-source project
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=54815820

http://code.google.com/p/google-guice/source/detail?r=e1197a962b65

Modified:
 /core/src/com/google/inject/internal/InternalFlags.java
 /pom.xml

=======================================
--- /core/src/com/google/inject/internal/InternalFlags.java Sat Oct 5 21:05:39 2013 UTC +++ /core/src/com/google/inject/internal/InternalFlags.java Wed Nov 13 07:06:31 2013 UTC
@@ -1,33 +1,36 @@
 package com.google.inject.internal;

-
+import java.util.Arrays;
+import java.util.logging.Logger;
 /**
  * Contains flags for Guice.
  */
 public class InternalFlags {
-
+ private final static Logger logger = Logger.getLogger(InternalFlags.class.getName());
   /**
    * The options for Guice stack trace collection.
    */
   public enum IncludeStackTraceOption {
-    // No stack trace collection
+    /** No stack trace collection */
     OFF,
-    // Minimum stack trace collection (Default)
+    /**  Minimum stack trace collection (Default) */
     ONLY_FOR_DECLARING_SOURCE,
-    // Full stack trace for everything
+    /** Full stack trace for everything */
     COMPLETE
   }


   public static IncludeStackTraceOption getIncludeStackTraceOption() {
-    String propertyValue = System.getProperty(
-        "guice_include_stack_traces");
-    if (IncludeStackTraceOption.OFF.name().equals(propertyValue)) {
-        return IncludeStackTraceOption.OFF;
+    String flag = System.getProperty("guice_include_stack_traces");
+    try {
+      return (flag == null || flag.length() == 0)
+          ? IncludeStackTraceOption.ONLY_FOR_DECLARING_SOURCE
+          : IncludeStackTraceOption.valueOf(flag);
+    } catch (IllegalArgumentException e) {
+      logger.warning(flag
+          + " is not a valid flag value for guice_include_stack_traces. "
+ + " Values must be one of " + Arrays.asList(IncludeStackTraceOption.values()));
+      return IncludeStackTraceOption.ONLY_FOR_DECLARING_SOURCE;
     }
-    if (IncludeStackTraceOption.COMPLETE.name().equals(propertyValue)) {
-        return IncludeStackTraceOption.COMPLETE;
-    }
-    return IncludeStackTraceOption.ONLY_FOR_DECLARING_SOURCE;
   }
 }
=======================================
--- /pom.xml    Sat Oct  5 21:05:39 2013 UTC
+++ /pom.xml    Wed Nov 13 07:06:31 2013 UTC
@@ -275,6 +275,32 @@
             <redirectTestOutputToFile>true</redirectTestOutputToFile>
             <!--<argLine>-Dguice_include_stack_traces=OFF</argLine>-->
           </configuration>
+          <executions>
+            <execution>
+              <id>stack-traces-off</id>
+              <phase>test</phase>
+              <goals><goal>test</goal></goals>
+              <configuration>
+                <argLine>-Dguice_include_stack_traces=OFF</argLine>
+              </configuration>
+            </execution>
+            <execution>
+              <id>stack-traces-complete</id>
+              <phase>test</phase>
+              <goals><goal>test</goal></goals>
+              <configuration>
+                <argLine>-Dguice_include_stack_traces=COMPLETE</argLine>
+              </configuration>
+            </execution>
+            <execution>
+              <id>default-test</id>
+              <phase>test</phase>
+              <goals><goal>test</goal></goals>
+              <configuration>
+ <argLine>-Dguice_include_stack_traces=ONLY_FOR_DECLARING_SOURCE</argLine>
+              </configuration>
+            </execution>
+          </executions>
         </plugin>
         <!--
          | Shared OSGi manifest configuration

==============================================================================
Revision: 338213332308
Author:   Christian Edward Gruber <[email protected]>
Date:     Wed Nov 13 07:07:22 2013 UTC
Log:      Make guice build with javac 8.

javac 8 is more restrictive about generic type inference in situations
involving raw types, which prevents guice from compiling. This change
allows guice to be compiled with javac 8.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=55855098

http://code.google.com/p/google-guice/source/detail?r=338213332308

Modified:
 /core/src/com/google/inject/internal/ProvidedByInternalFactory.java
 /core/src/com/google/inject/spi/DefaultBindingTargetVisitor.java

=======================================
--- /core/src/com/google/inject/internal/ProvidedByInternalFactory.java Mon Feb 27 02:23:19 2012 UTC +++ /core/src/com/google/inject/internal/ProvidedByInternalFactory.java Wed Nov 13 07:07:22 2013 UTC
@@ -58,8 +58,7 @@
     providerBinding =
injector.getBindingOrThrow(providerKey, errors, JitLimitation.NEW_OR_EXISTING_JIT);
   }
-
-  @SuppressWarnings("unchecked")//
+
public T get(Errors errors, InternalContext context, Dependency dependency, boolean linked)
       throws ErrorsException {
     checkState(providerBinding != null, "not initialized");
@@ -67,7 +66,7 @@
     context.pushState(providerKey, providerBinding.getSource());
     try {
       errors = errors.withSource(providerKey);
-      Provider provider = providerBinding.getInternalFactory().get(
+ Provider<? extends T> provider = providerBinding.getInternalFactory().get(
           errors, context, dependency, true);
return circularGet(provider, errors, context, dependency, linked, provisionCallback);
     } finally {
=======================================
--- /core/src/com/google/inject/spi/DefaultBindingTargetVisitor.java Thu Oct 21 19:10:16 2010 UTC +++ /core/src/com/google/inject/spi/DefaultBindingTargetVisitor.java Wed Nov 13 07:07:22 2013 UTC
@@ -69,9 +69,9 @@
     return visitOther(convertedConstantBinding);
   }

- // javac says it's an error to cast ProviderBinding<? extends T> to Binding<? extends T>
   @SuppressWarnings("unchecked")
   public V visit(ProviderBinding<? extends T> providerBinding) {
-    return visitOther((Binding) providerBinding);
+ // TODO(cushon): remove raw (Binding) cast when we don't care about javac 6 anymore
+    return visitOther((Binding<? extends T>) (Binding) providerBinding);
   }
 }

--
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice-dev.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to