Adds part of Java 7 new language features.

Adds the Java 7 new language features: namely, the diamond operator, new numerical
literal formats, and switch/case on string literals.

Adds a new flag -source to select source level compatibility (java 6 or java 7);
-source defaults to java 6.

Fixes issue 6633.

Change-Id: I91c1f39ff20a2e7ac131d647bf4c96e34ce47a70
Review-Link: https://gwt-review.googlesource.com/#/c/2650/
diff --git a/dev/codeserver/java/com/google/gwt/dev/codeserver/CodeServer.java b/dev/codeserver/java/com/google/gwt/dev/codeserver/CodeServer.java
index 01f3a65..2641b5d 100644
--- a/dev/codeserver/java/com/google/gwt/dev/codeserver/CodeServer.java
+++ b/dev/codeserver/java/com/google/gwt/dev/codeserver/CodeServer.java
@@ -116,9 +116,9 @@
     for (String moduleName : options.getModuleNames()) {
       AppSpace appSpace = AppSpace.create(new File(workDir, moduleName));
 
-      Recompiler recompiler = new Recompiler(appSpace, moduleName,
-          options.getSourcePath(), options.getPreferredHost() + ":" + options.getPort(),
-          options.getRecompileListener(), options.isCompileTest(), logger);
+      Recompiler recompiler = new Recompiler(appSpace, moduleName, options.getSourcePath(),
+          options.getPreferredHost() + ":" + options.getPort(), options.getRecompileListener(),
+          options.isCompileTest(), options.getSourceLevel(), logger);
       modules.addModuleState(new ModuleState(recompiler, logger, options.getNoPrecompile()));
     }
     return modules;
diff --git a/dev/codeserver/java/com/google/gwt/dev/codeserver/CompilerOptionsImpl.java b/dev/codeserver/java/com/google/gwt/dev/codeserver/CompilerOptionsImpl.java
index 2b4f76e..c8229b9 100644
--- a/dev/codeserver/java/com/google/gwt/dev/codeserver/CompilerOptionsImpl.java
+++ b/dev/codeserver/java/com/google/gwt/dev/codeserver/CompilerOptionsImpl.java
@@ -19,6 +19,7 @@
 import com.google.gwt.core.ext.TreeLogger;
 import com.google.gwt.dev.jjs.JsOutputOption;
 import com.google.gwt.dev.util.arg.OptionOptimize;
+import com.google.gwt.dev.util.arg.SourceLevel;
 
 import java.io.File;
 import java.util.Arrays;
@@ -31,10 +32,12 @@
 class CompilerOptionsImpl extends UnmodifiableCompilerOptions {
   private final CompileDir compileDir;
   private final String moduleName;
+  private final SourceLevel sourceLevel;
 
-  CompilerOptionsImpl(CompileDir compileDir, String moduleName) {
+  CompilerOptionsImpl(CompileDir compileDir, String moduleName, SourceLevel sourceLevel) {
     this.compileDir = compileDir;
     this.moduleName = moduleName;
+    this.sourceLevel = sourceLevel;
   }
 
   @Override
@@ -51,7 +54,7 @@
   public int getFragmentCount() {
     return -1;
   }
-  
+
   @Override
   public int getFragmentsMerge() {
     return -1;
@@ -101,6 +104,11 @@
   }
 
   @Override
+  public SourceLevel getSourceLevel() {
+    return sourceLevel;
+  }
+
+  @Override
   public File getWarDir() {
     return compileDir.getWarDir();
   }
diff --git a/dev/codeserver/java/com/google/gwt/dev/codeserver/Options.java b/dev/codeserver/java/com/google/gwt/dev/codeserver/Options.java
index ab3a83b..e16534f 100644
--- a/dev/codeserver/java/com/google/gwt/dev/codeserver/Options.java
+++ b/dev/codeserver/java/com/google/gwt/dev/codeserver/Options.java
@@ -17,6 +17,9 @@
 package com.google.gwt.dev.codeserver;
 
 import com.google.gwt.dev.ArgProcessorBase;
+import com.google.gwt.dev.util.arg.ArgHandlerSource;
+import com.google.gwt.dev.util.arg.OptionSource;
+import com.google.gwt.dev.util.arg.SourceLevel;
 import com.google.gwt.util.tools.ArgHandler;
 import com.google.gwt.util.tools.ArgHandlerDir;
 import com.google.gwt.util.tools.ArgHandlerExtra;
@@ -46,6 +49,8 @@
   private String preferredHost = "localhost";
   private int port = 9876;
   private RecompileListener recompileListener = RecompileListener.NONE;
+  // Use the same default as the GWT compiler.
+  private SourceLevel sourceLevel = OptionSource.DEFAULT_SOURCE_LEVEL;
 
   /**
    * Sets each option to the appropriate value, based on command-line arguments.
@@ -112,6 +117,13 @@
   }
 
   /**
+   * Java source level compatibility,
+   */
+  SourceLevel getSourceLevel() {
+    return sourceLevel;
+  }
+
+  /**
    * If true, just compile the modules, then exit.
    */
   boolean isCompileTest() {
@@ -154,6 +166,17 @@
       registerHandler(new AllowMissingSourceDirFlag());
       registerHandler(new SourceFlag());
       registerHandler(new ModuleNameArgument());
+      registerHandler(new ArgHandlerSource(new OptionSource() {
+        @Override
+        public SourceLevel getSourceLevel() {
+          return sourceLevel;
+        }
+
+        @Override
+        public void setSourceLevel(SourceLevel sourceLevel) {
+          Options.this.sourceLevel = sourceLevel;
+        }
+      }));
     }
 
     @Override
diff --git a/dev/codeserver/java/com/google/gwt/dev/codeserver/Recompiler.java b/dev/codeserver/java/com/google/gwt/dev/codeserver/Recompiler.java
index 025c2b9..24360c1 100644
--- a/dev/codeserver/java/com/google/gwt/dev/codeserver/Recompiler.java
+++ b/dev/codeserver/java/com/google/gwt/dev/codeserver/Recompiler.java
@@ -33,6 +33,7 @@
 import com.google.gwt.dev.javac.CompilationStateBuilder;
 import com.google.gwt.dev.resource.impl.ResourceOracleImpl;
 import com.google.gwt.dev.resource.impl.ZipFileClassPathEntry;
+import com.google.gwt.dev.util.arg.SourceLevel;
 import com.google.gwt.dev.util.log.CompositeTreeLogger;
 import com.google.gwt.dev.util.log.PrintWriterTreeLogger;
 
@@ -55,6 +56,7 @@
   private final TreeLogger logger;
   private String serverPrefix;
   private int compilesDone = 0;
+  private SourceLevel sourceLevel;
 
   // after renaming
   private AtomicReference<String> moduleName = new AtomicReference<String>(null);
@@ -65,7 +67,7 @@
 
   Recompiler(AppSpace appSpace, String moduleName, List<File> sourcePath,
       String serverPrefix, RecompileListener listener, boolean failIfListenerFails,
-      TreeLogger logger) {
+      SourceLevel sourceLevel, TreeLogger logger) {
     this.appSpace = appSpace;
     this.originalModuleName = moduleName;
     this.sourcePath = sourcePath;
@@ -73,6 +75,7 @@
     this.failIfListenerFails = failIfListenerFails;
     this.logger = logger;
     this.serverPrefix = serverPrefix;
+    this.sourceLevel = sourceLevel;
   }
 
   synchronized CompileDir compile(Map<String, String> bindingProperties)
@@ -101,13 +104,12 @@
 
     boolean success = false;
     try {
-
       ModuleDef module = loadModule(compileLogger, bindingProperties);
       String newModuleName = module.getName(); // includes any rename
       moduleName.set(newModuleName);
 
 
-      CompilerOptions options = new CompilerOptionsImpl(compileDir, newModuleName);
+      CompilerOptions options = new CompilerOptionsImpl(compileDir, newModuleName, sourceLevel);
 
       success = new Compiler(options).run(compileLogger, module);
       lastBuild.set(compileDir); // makes compile log available over HTTP
diff --git a/dev/codeserver/java/com/google/gwt/dev/codeserver/UnmodifiableCompilerOptions.java b/dev/codeserver/java/com/google/gwt/dev/codeserver/UnmodifiableCompilerOptions.java
index 865f095..c0d6db3 100644
--- a/dev/codeserver/java/com/google/gwt/dev/codeserver/UnmodifiableCompilerOptions.java
+++ b/dev/codeserver/java/com/google/gwt/dev/codeserver/UnmodifiableCompilerOptions.java
@@ -19,6 +19,7 @@
 import com.google.gwt.core.ext.TreeLogger;
 import com.google.gwt.dev.CompilerOptions;
 import com.google.gwt.dev.jjs.JsOutputOption;
+import com.google.gwt.dev.util.arg.SourceLevel;
 
 import java.io.File;
 import java.util.List;
@@ -173,6 +174,11 @@
   }
 
   @Override
+  public final void setSourceLevel(SourceLevel sourceLevel) {
+    throw new UnsupportedOperationException();
+  }
+
+  @Override
   public final void setSoycEnabled(boolean enabled) {
     throw new UnsupportedOperationException();
   }
diff --git a/dev/core/src/com/google/gwt/dev/CompileModule.java b/dev/core/src/com/google/gwt/dev/CompileModule.java
index 8ba6fb5..eb30158 100644
--- a/dev/core/src/com/google/gwt/dev/CompileModule.java
+++ b/dev/core/src/com/google/gwt/dev/CompileModule.java
@@ -275,7 +275,8 @@
 
       CompilationState compilationState;
       try {
-        compilationState = module.getCompilationState(logger, !options.isStrict());
+        compilationState = module.getCompilationState(logger, !options.isStrict(),
+            options.getSourceLevel());
       } catch (Throwable e) {
         CompilationProblemReporter.logAndTranslateException(logger, e);
         return false;
diff --git a/dev/core/src/com/google/gwt/dev/CompileTaskOptions.java b/dev/core/src/com/google/gwt/dev/CompileTaskOptions.java
index 8b04846..d04f316 100644
--- a/dev/core/src/com/google/gwt/dev/CompileTaskOptions.java
+++ b/dev/core/src/com/google/gwt/dev/CompileTaskOptions.java
@@ -17,10 +17,12 @@
 
 import com.google.gwt.dev.util.arg.OptionLogLevel;
 import com.google.gwt.dev.util.arg.OptionModuleName;
+import com.google.gwt.dev.util.arg.OptionSource;
 import com.google.gwt.dev.util.arg.OptionWorkDir;
 
 /**
  * A common set of options for all compile tasks.
  */
-public interface CompileTaskOptions extends OptionModuleName, OptionLogLevel, OptionWorkDir {
+public interface CompileTaskOptions extends OptionModuleName, OptionLogLevel, OptionWorkDir,
+    OptionSource {
 }
diff --git a/dev/core/src/com/google/gwt/dev/CompileTaskOptionsImpl.java b/dev/core/src/com/google/gwt/dev/CompileTaskOptionsImpl.java
index 3855eb8..34cceb6 100644
--- a/dev/core/src/com/google/gwt/dev/CompileTaskOptionsImpl.java
+++ b/dev/core/src/com/google/gwt/dev/CompileTaskOptionsImpl.java
@@ -16,6 +16,8 @@
 package com.google.gwt.dev;
 
 import com.google.gwt.core.ext.TreeLogger.Type;
+import com.google.gwt.dev.util.arg.OptionSource;
+import com.google.gwt.dev.util.arg.SourceLevel;
 
 import java.io.File;
 import java.util.ArrayList;
@@ -29,6 +31,7 @@
   private Type logLevel;
   private final List<String> moduleNames = new ArrayList<String>();
   private File workDir;
+  private SourceLevel sourceLevel = OptionSource.DEFAULT_SOURCE_LEVEL;
 
   public CompileTaskOptionsImpl() {
   }
@@ -75,4 +78,14 @@
   public void setWorkDir(File workDir) {
     this.workDir = workDir;
   }
+
+  @Override
+  public SourceLevel getSourceLevel() {
+    return sourceLevel;
+  }
+
+  @Override
+  public void setSourceLevel(SourceLevel sourceLevel) {
+    this.sourceLevel = sourceLevel;
+  }
 }
diff --git a/dev/core/src/com/google/gwt/dev/Compiler.java b/dev/core/src/com/google/gwt/dev/Compiler.java
index ca97510..994bfec 100644
--- a/dev/core/src/com/google/gwt/dev/Compiler.java
+++ b/dev/core/src/com/google/gwt/dev/Compiler.java
@@ -33,6 +33,7 @@
 import com.google.gwt.dev.util.arg.ArgHandlerDeployDir;
 import com.google.gwt.dev.util.arg.ArgHandlerExtraDir;
 import com.google.gwt.dev.util.arg.ArgHandlerLocalWorkers;
+import com.google.gwt.dev.util.arg.ArgHandlerSource;
 import com.google.gwt.dev.util.arg.ArgHandlerWarDir;
 import com.google.gwt.dev.util.arg.ArgHandlerWorkDirOptional;
 import com.google.gwt.dev.util.log.speedtracer.CompilerEventType;
@@ -62,6 +63,7 @@
       registerHandler(new ArgHandlerWarDir(options));
       registerHandler(new ArgHandlerDeployDir(options));
       registerHandler(new ArgHandlerExtraDir(options));
+      registerHandler(new ArgHandlerSource(options));
     }
 
     @Override
diff --git a/dev/core/src/com/google/gwt/dev/DevMode.java b/dev/core/src/com/google/gwt/dev/DevMode.java
index 47845a4..658eecd 100644
--- a/dev/core/src/com/google/gwt/dev/DevMode.java
+++ b/dev/core/src/com/google/gwt/dev/DevMode.java
@@ -36,6 +36,7 @@
 import com.google.gwt.dev.util.arg.ArgHandlerDisableUpdateCheck;
 import com.google.gwt.dev.util.arg.ArgHandlerExtraDir;
 import com.google.gwt.dev.util.arg.ArgHandlerModuleName;
+import com.google.gwt.dev.util.arg.ArgHandlerSource;
 import com.google.gwt.dev.util.arg.ArgHandlerWarDir;
 import com.google.gwt.dev.util.arg.ArgHandlerWorkDirOptional;
 import com.google.gwt.dev.util.log.speedtracer.DevModeEventType;
@@ -182,6 +183,7 @@
       registerHandler(new ArgHandlerExtraDir(options));
       registerHandler(new ArgHandlerWorkDirOptional(options));
       registerHandler(new ArgHandlerDisableUpdateCheck(options));
+      registerHandler(new ArgHandlerSource(options));
       registerHandler(new ArgHandlerModuleName(options) {
         @Override
         public String getPurpose() {
diff --git a/dev/core/src/com/google/gwt/dev/DevModeBase.java b/dev/core/src/com/google/gwt/dev/DevModeBase.java
index 1440210..2849629 100644
--- a/dev/core/src/com/google/gwt/dev/DevModeBase.java
+++ b/dev/core/src/com/google/gwt/dev/DevModeBase.java
@@ -106,7 +106,7 @@
         ArchivePreloader.preloadArchives(logger, moduleDef);
         
         CompilationState compilationState =
-            moduleDef.getCompilationState(logger, !options.isStrict());
+            moduleDef.getCompilationState(logger, !options.isStrict(), options.getSourceLevel());
         ShellModuleSpaceHost host =
             doCreateShellModuleSpaceHost(logger, compilationState, moduleDef);
         return host;
diff --git a/dev/core/src/com/google/gwt/dev/Precompile.java b/dev/core/src/com/google/gwt/dev/Precompile.java
index 323fc67..a224c93 100644
--- a/dev/core/src/com/google/gwt/dev/Precompile.java
+++ b/dev/core/src/com/google/gwt/dev/Precompile.java
@@ -155,7 +155,7 @@
     Event validateEvent = SpeedTracerLogger.start(CompilerEventType.VALIDATE);
     try {
       CompilationState compilationState =
-          module.getCompilationState(logger, !jjsOptions.isStrict());
+          module.getCompilationState(logger, !jjsOptions.isStrict(), jjsOptions.getSourceLevel());
       if (jjsOptions.isStrict() && compilationState.hasErrors()) {
         abortDueToStrictMode(logger);
       }
@@ -244,7 +244,7 @@
 
     try {
       CompilationState compilationState =
-          module.getCompilationState(logger, !jjsOptions.isStrict());
+          module.getCompilationState(logger, !jjsOptions.isStrict(), jjsOptions.getSourceLevel());
       if (jjsOptions.isStrict() && compilationState.hasErrors()) {
         abortDueToStrictMode(logger);
       }
diff --git a/dev/core/src/com/google/gwt/dev/cfg/ModuleDef.java b/dev/core/src/com/google/gwt/dev/cfg/ModuleDef.java
index 378ab1a..579275d 100644
--- a/dev/core/src/com/google/gwt/dev/cfg/ModuleDef.java
+++ b/dev/core/src/com/google/gwt/dev/cfg/ModuleDef.java
@@ -33,6 +33,8 @@
 import com.google.gwt.dev.resource.impl.ResourceOracleImpl;
 import com.google.gwt.dev.util.Empty;
 import com.google.gwt.dev.util.Util;
+import com.google.gwt.dev.util.arg.OptionSource;
+import com.google.gwt.dev.util.arg.SourceLevel;
 import com.google.gwt.dev.util.log.speedtracer.CompilerEventType;
 import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger;
 import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger.Event;
@@ -364,15 +366,16 @@
   }
 
   public CompilationState getCompilationState(TreeLogger logger) throws UnableToCompleteException {
-    return getCompilationState(logger, false);
+    return getCompilationState(logger, false, OptionSource.DEFAULT_SOURCE_LEVEL);
   }
 
-  public synchronized CompilationState getCompilationState(TreeLogger logger, boolean suppressErrors)
+  public synchronized CompilationState getCompilationState(TreeLogger logger,
+      boolean suppressErrors, SourceLevel sourceLevel)
       throws UnableToCompleteException {
     doRefresh();
     CompilationState compilationState =
         CompilationStateBuilder.buildFrom(logger, lazySourceOracle.getResources(), null,
-            suppressErrors);
+            suppressErrors, sourceLevel);
     checkForSeedTypes(logger, compilationState);
     return compilationState;
   }
diff --git a/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java b/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java
index 99c3770..fc359db 100644
--- a/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java
+++ b/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java
@@ -25,6 +25,8 @@
 import com.google.gwt.dev.js.ast.JsRootScope;
 import com.google.gwt.dev.resource.Resource;
 import com.google.gwt.dev.util.StringInterner;
+import com.google.gwt.dev.util.arg.OptionSource;
+import com.google.gwt.dev.util.arg.SourceLevel;
 import com.google.gwt.dev.util.log.speedtracer.CompilerEventType;
 import com.google.gwt.dev.util.log.speedtracer.DevModeEventType;
 import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger;
@@ -154,7 +156,7 @@
     /**
      * The JDT compiler.
      */
-    private final JdtCompiler compiler = new JdtCompiler(new UnitProcessorImpl());
+    private final JdtCompiler compiler;
 
     /**
      * Continuation state for JSNI checking.
@@ -164,7 +166,9 @@
 
     private final boolean suppressErrors;
 
-    public CompileMoreLater(AdditionalTypeProviderDelegate delegate, boolean suppressErrors) {
+    public CompileMoreLater(AdditionalTypeProviderDelegate delegate, boolean suppressErrors,
+        SourceLevel sourceLevel) {
+      this.compiler = new JdtCompiler(new UnitProcessorImpl(), sourceLevel);
       compiler.setAdditionalTypeProviderDelegate(delegate);
       this.suppressErrors = suppressErrors;
     }
@@ -402,12 +406,13 @@
 
   public static CompilationState buildFrom(TreeLogger logger, Set<Resource> resources)
       throws UnableToCompleteException {
-    return buildFrom(logger, resources, null, false);
+    return buildFrom(logger, resources, null, false, OptionSource.DEFAULT_SOURCE_LEVEL);
   }
 
   public static CompilationState buildFrom(TreeLogger logger, Set<Resource> resources,
-      AdditionalTypeProviderDelegate delegate) throws UnableToCompleteException {
-    return buildFrom(logger, resources, delegate, false);
+      AdditionalTypeProviderDelegate delegate, SourceLevel sourceLevel)
+      throws UnableToCompleteException {
+    return buildFrom(logger, resources, delegate, false, sourceLevel);
   }
 
   /**
@@ -416,11 +421,12 @@
    * @throws UnableToCompleteException if the compiler aborts (not a normal compile error).
    */
   public static CompilationState buildFrom(TreeLogger logger, Set<Resource> resources,
-      AdditionalTypeProviderDelegate delegate, boolean suppressErrors)
+      AdditionalTypeProviderDelegate delegate, boolean suppressErrors,
+      SourceLevel sourceLevel)
       throws UnableToCompleteException {
     Event event = SpeedTracerLogger.start(DevModeEventType.CSB_BUILD_FROM_ORACLE);
     try {
-      return instance.doBuildFrom(logger, resources, delegate, suppressErrors);
+      return instance.doBuildFrom(logger, resources, delegate, suppressErrors, sourceLevel);
     } finally {
       event.end();
     }
@@ -451,7 +457,8 @@
    * TODO: maybe use a finer brush than to synchronize the whole thing.
    */
   public synchronized CompilationState doBuildFrom(TreeLogger logger, Set<Resource> resources,
-      AdditionalTypeProviderDelegate compilerDelegate, boolean suppressErrors)
+      AdditionalTypeProviderDelegate compilerDelegate, boolean suppressErrors,
+      SourceLevel sourceLevel)
     throws UnableToCompleteException {
 
     // Units we definitely want to build.
@@ -461,7 +468,8 @@
     Map<CompilationUnitBuilder, CompilationUnit> cachedUnits =
         new IdentityHashMap<CompilationUnitBuilder, CompilationUnit>();
 
-    CompileMoreLater compileMoreLater = new CompileMoreLater(compilerDelegate, suppressErrors);
+    CompileMoreLater compileMoreLater = new CompileMoreLater(compilerDelegate, suppressErrors,
+        sourceLevel);
 
     // For each incoming Java source file...
     for (Resource resource : resources) {
@@ -503,8 +511,9 @@
   }
 
   public CompilationState doBuildFrom(TreeLogger logger, Set<Resource> resources,
-      boolean suppressErrors) throws UnableToCompleteException {
-    return doBuildFrom(logger, resources, null, suppressErrors);
+      boolean suppressErrors, SourceLevel sourceLevel)
+      throws UnableToCompleteException {
+    return doBuildFrom(logger, resources, null, suppressErrors, sourceLevel);
   }
 
   /**
diff --git a/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java b/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java
index 8d24f22..512a871 100644
--- a/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java
+++ b/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java
@@ -21,10 +21,13 @@
 import com.google.gwt.dev.jjs.InternalCompilerException;
 import com.google.gwt.dev.jjs.ast.JDeclaredType;
 import com.google.gwt.dev.util.Name.BinaryName;
+import com.google.gwt.dev.util.arg.OptionSource;
+import com.google.gwt.dev.util.arg.SourceLevel;
 import com.google.gwt.dev.util.collect.Lists;
 import com.google.gwt.dev.util.log.speedtracer.CompilerEventType;
 import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger;
 import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger.Event;
+import com.google.gwt.thirdparty.guava.common.collect.ImmutableMap;
 import com.google.gwt.util.tools.Utility;
 
 import org.eclipse.jdt.core.compiler.CharOperation;
@@ -385,9 +388,9 @@
     private TreeLogger logger;
     private int abortCount = 0;
 
-    public CompilerImpl(TreeLogger logger) {
+    public CompilerImpl(TreeLogger logger, CompilerOptions compilerOptions) {
       super(new INameEnvironmentImpl(), DefaultErrorHandlingPolicies.proceedWithAllProblems(),
-          getCompilerOptions(), new ICompilerRequestorImpl(), new DefaultProblemFactory(
+          compilerOptions, new ICompilerRequestorImpl(), new DefaultProblemFactory(
               Locale.getDefault()));
       this.logger = logger;
     }
@@ -594,11 +597,17 @@
   public static List<CompilationUnit> compile(TreeLogger logger,
       Collection<CompilationUnitBuilder> builders)
       throws UnableToCompleteException {
+    return compile(logger, builders, OptionSource.DEFAULT_SOURCE_LEVEL);
+  }
+
+  public static List<CompilationUnit> compile(TreeLogger logger,
+      Collection<CompilationUnitBuilder> builders, SourceLevel sourceLevel)
+      throws UnableToCompleteException {
     Event jdtCompilerEvent = SpeedTracerLogger.start(CompilerEventType.JDT_COMPILER);
 
     try {
       DefaultUnitProcessor processor = new DefaultUnitProcessor();
-      JdtCompiler compiler = new JdtCompiler(processor);
+      JdtCompiler compiler = new JdtCompiler(processor, sourceLevel);
       compiler.doCompile(logger, builders);
       return processor.getResults();
     } finally {
@@ -606,14 +615,20 @@
     }
   }
 
-  public static CompilerOptions getCompilerOptions() {
+
+  public static CompilerOptions getStandardCompilerOptions() {
     CompilerOptions options = new CompilerOptions() {
       {
         warningThreshold.clearAll();
       }
     };
-    options.originalSourceLevel = options.complianceLevel = options.sourceLevel =
-        options.targetJDK = ClassFileConstants.JDK1_6;
+
+    long jdtSourceLevel = jdtLevelByGwtLevel.get(OptionSource.DEFAULT_SOURCE_LEVEL);
+
+    options.originalSourceLevel = jdtSourceLevel;
+    options.complianceLevel = jdtSourceLevel;
+    options.sourceLevel = jdtSourceLevel;
+    options.targetJDK = jdtSourceLevel;
 
     // Generate debug info for debugging the output.
     options.produceDebugAttributes =
@@ -631,6 +646,17 @@
     return options;
   }
 
+  public CompilerOptions getCompilerOptions() {
+    CompilerOptions options = getStandardCompilerOptions();
+    long jdtSourceLevel = jdtLevelByGwtLevel.get(sourceLevel);
+
+    options.originalSourceLevel = jdtSourceLevel;
+    options.complianceLevel = jdtSourceLevel;
+    options.sourceLevel = jdtSourceLevel;
+    options.targetJDK = jdtSourceLevel;
+    return options;
+  }
+
   public static ReferenceBinding resolveType(LookupEnvironment lookupEnvironment, String typeName) {
     ReferenceBinding type = null;
 
@@ -723,8 +749,23 @@
 
   private final UnitProcessor processor;
 
-  public JdtCompiler(UnitProcessor processor) {
+  /**
+   * Java source level compatibility.
+   */
+  private final SourceLevel sourceLevel;
+
+  /**
+   * Maps from SourceLevel, the GWT compiler Java source compatibility levels, to JDT
+   * Java source compatibility levels.
+   */
+  private static final Map<SourceLevel, Long> jdtLevelByGwtLevel =
+      ImmutableMap.<SourceLevel, Long>of(
+          SourceLevel.JAVA6, ClassFileConstants.JDK1_6,
+          SourceLevel.JAVA7, ClassFileConstants.JDK1_7);
+
+  public JdtCompiler(UnitProcessor processor, SourceLevel sourceLevel) {
     this.processor = processor;
+    this.sourceLevel = sourceLevel;
   }
 
   public void addCompiledUnit(CompilationUnit unit) {
@@ -936,7 +977,7 @@
       icus.add(new Adapter(builder));
     }
 
-    compilerImpl = new CompilerImpl(logger);
+    compilerImpl = new CompilerImpl(logger, getCompilerOptions());
     try {
       compilerImpl.compile(icus.toArray(new ICompilationUnit[icus.size()]));
     } catch (AbortCompilation e) {
diff --git a/dev/core/src/com/google/gwt/dev/javac/testing/GeneratorContextBuilder.java b/dev/core/src/com/google/gwt/dev/javac/testing/GeneratorContextBuilder.java
index 2aa2dc6..d13d733 100644
--- a/dev/core/src/com/google/gwt/dev/javac/testing/GeneratorContextBuilder.java
+++ b/dev/core/src/com/google/gwt/dev/javac/testing/GeneratorContextBuilder.java
@@ -24,6 +24,7 @@
 import com.google.gwt.dev.javac.testing.impl.JavaResourceBase;
 import com.google.gwt.dev.javac.testing.impl.MockResource;
 import com.google.gwt.dev.resource.Resource;
+import com.google.gwt.dev.util.arg.OptionSource;
 import com.google.gwt.dev.util.collect.HashSet;
 import com.google.gwt.dev.util.log.PrintWriterTreeLogger;
 
@@ -104,7 +105,8 @@
 
   private CompilationState buildCompilationState() throws UnableToCompleteException {
     TreeLogger logger = treeLogger != null ? treeLogger : createLogger();
-      return new CompilationStateBuilder().doBuildFrom(logger, resources, null, false);
+      return new CompilationStateBuilder().doBuildFrom(logger, resources, null, false,
+          OptionSource.DEFAULT_SOURCE_LEVEL);
   }
 
   private TreeLogger createLogger() {
diff --git a/dev/core/src/com/google/gwt/dev/javac/testing/impl/Java7MockResources.java b/dev/core/src/com/google/gwt/dev/javac/testing/impl/Java7MockResources.java
new file mode 100644
index 0000000..18f64be
--- /dev/null
+++ b/dev/core/src/com/google/gwt/dev/javac/testing/impl/Java7MockResources.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.dev.javac.testing.impl;
+
+/**
+ * Contains Java 7 source files used for testing.
+ */
+public class Java7MockResources {
+  public static final MockJavaResource NEW_INTEGER_LITERALS_TEST =
+      JavaResourceBase.createMockJavaResource("com.google.gwt.NewIntegerLiteralsTest",
+          "package com.google.gwt;",
+          "public class NewIntegerLiteralsTest {",
+          "  int million = 1_000_000;",
+          "}");
+
+  public static final MockJavaResource SWITCH_ON_STRINGS_TEST =
+      JavaResourceBase.createMockJavaResource("com.google.gwt.SwitchOnStringsTest",
+          "package com.google.gwt;",
+          "public class SwitchOnStringsTest {",
+          "  int test() {",
+          "    int result = 0;",
+          "    String f = \"AA\";",
+          "    switch(f) {",
+          "      case \"CC\": result = - 1; break;",
+          "      case \"BB\": result = 1;",
+          "      case \"AA\": result = result + 1; break;",
+          "      default: result = -2; break;",
+          "    }",
+          "  return result;",
+          "  }",
+          "}");
+
+  public static final MockJavaResource DIAMOND_OPERATOR_TEST =
+      JavaResourceBase.createMockJavaResource("com.google.gwt.DiamondOperatorTest",
+          "package com.google.gwt;",
+          "import com.google.gwt.List;",
+          "import com.google.gwt.ArrayList;",
+          "public class DiamondOperatorTest {",
+          "  void test() {",
+          "    List<String> list = new ArrayList<>();",
+          "  }  ",
+          "}");
+
+  public static final MockJavaResource TRY_WITH_RESOURCES_TEST =
+      JavaResourceBase.createMockJavaResource("com.google.gwt.TryWithResourcesTest",
+          "package com.google.gwt;",
+          "import com.google.gwt.TestResource;",
+          "public class TryWithResourcesTest {",
+          "  void test() { ",
+          "    try (TestResource tr1 = new TestResource(); ",
+          "         TestResource tr2 = new TestResource()) {",
+          "    }  ",
+          "  }  ",
+          "}");
+
+  public static final MockJavaResource MULTI_EXCEPTION_TEST =
+      JavaResourceBase.createMockJavaResource("com.google.gwt.MultiExceptionTest",
+          "package com.google.gwt;",
+          "import com.google.gwt.Exception1;",
+          "import com.google.gwt.Exception2;",
+          "public class MultiExceptionTest {",
+          "  void test() { ",
+          "    int i = 1;",
+          "    try {",
+          "      if (i > 0) {",
+          "        throw new Exception1();",
+          "      } else {",
+          "        throw new Exception2();",
+          "      }",
+          "    } catch (Exception1 | Exception2 e) { ",
+          "    }",
+          "  } ",
+          "}");
+
+  public static final MockJavaResource LIST_T =
+      JavaResourceBase.createMockJavaResource("com.google.gwt.List",
+          "package com.google.gwt;",
+          "public interface List<T> {",
+          "  T method1();",
+          "}");
+
+  public static final MockJavaResource ARRAYLIST_T =
+      JavaResourceBase.createMockJavaResource("com.google.gwt.ArrayList",
+          "package com.google.gwt;",
+          "import com.google.gwt.List;",
+          "public class ArrayList<T> implements List<T> {",
+          "  public T method1() { return null; }",
+          "}");
+
+  public static final MockJavaResource TEST_RESOURCE =
+      JavaResourceBase.createMockJavaResource("com.google.gwt.TestResource",
+          "package com.google.gwt;",
+          "public class TestResource implements AutoCloseable {",
+          "  public void close() { }",
+          "}");
+
+  public static final MockJavaResource EXCEPTION1 =
+      JavaResourceBase.createMockJavaResource("com.google.gwt.Exception1",
+          "package com.google.gwt;",
+          "import java.lang.Exception;",
+          "public class Exception1 extends Exception {",
+          "}");
+
+  public static final MockJavaResource EXCEPTION2 =
+      JavaResourceBase.createMockJavaResource("com.google.gwt.Exception2",
+          "package com.google.gwt;",
+          "import java.lang.Exception;",
+          "public class Exception2 extends Exception {",
+          "}");
+}
diff --git a/dev/core/src/com/google/gwt/dev/javac/testing/impl/JavaResourceBase.java b/dev/core/src/com/google/gwt/dev/javac/testing/impl/JavaResourceBase.java
index ea413fb..42906c0 100644
--- a/dev/core/src/com/google/gwt/dev/javac/testing/impl/JavaResourceBase.java
+++ b/dev/core/src/com/google/gwt/dev/javac/testing/impl/JavaResourceBase.java
@@ -19,395 +19,300 @@
  * Contains standard Java source files for testing.
  */
 public class JavaResourceBase {
+  public static final MockJavaResource AUTOCLOSEABLE =
+      createMockJavaResource("java.lang.AutoCloseable",
+          "package java.lang;",
+          "import java.lang.Exception;",
+          "public interface AutoCloseable {",
+          "  void close() throws Exception; ",
+          "}");
 
-  public static final MockJavaResource ANNOTATION = new MockJavaResource(
-      "java.lang.annotation.Annotation") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package java.lang.annotation;\n");
-      code.append("public interface Annotation {\n");
-      code.append("}\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource BAR = new MockJavaResource("test.Bar") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package test;\n");
-      code.append("public class Bar extends Foo {\n");
-      code.append("  public String value() { return \"Bar\"; }\n");
-      code.append("}\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource BOOLEAN = new MockJavaResource("java.lang.Boolean") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package java.lang;\n");
-      code.append("public class Boolean {\n");
-      code.append("  private boolean value;\n");
-      code.append("  public Boolean(boolean value) {\n");
-      code.append("    this.value = value;\n");
-      code.append("  }\n");
-      code.append("  public static Boolean valueOf(boolean b) { return new Boolean(b); }\n");
-      code.append("  public boolean booleanValue() { return value; }\n");
-      code.append("}\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource BYTE = new MockJavaResource("java.lang.Byte") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package java.lang;\n");
-      code.append("public class Byte extends Number {\n");
-      code.append("  private byte value;\n");
-      code.append("  public Byte(byte value) {\n");
-      code.append("    this.value = value;\n");
-      code.append("  }\n");
-      code.append("  public static Byte valueOf(byte b) { return new Byte(b); }\n");
-      code.append("  public byte byteValue() { return value; }\n");
-      code.append("}\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource CHARACTER = new MockJavaResource("java.lang.Character") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package java.lang;\n");
-      code.append("public class Character {\n");
-      code.append("  private char value;\n");
-      code.append("  public Character(char value) {\n");
-      code.append("    this.value = value;\n");
-      code.append("  }\n");
-      code.append("  public static Character valueOf(char c) { return new Character(c); }\n");
-      code.append("  public char charValue() { return value; }\n");
-      code.append("}\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource CLASS = new MockJavaResource("java.lang.Class") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package java.lang;\n");
-      code.append("public class Class<T> {\n");
-      code.append("  public String getName() { return null; }\n");
-      code.append("  public String getSimpleName() { return null; }\n");
-      code.append("}\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource CLASS_NOT_FOUND_EXCEPTION = new MockJavaResource(
-      "java.lang.ClassNotFoundException") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package java.lang;\n");
-      code.append("public class ClassNotFoundException extends Exception {\n");
-      code.append("  public ClassNotFoundException() {}\n");
-      code.append("  public ClassNotFoundException(String msg) {}\n");
-      code.append("  public ClassNotFoundException(String msg, Throwable t) {}\n");
-      code.append("  public Throwable getCause() { return null; }\n");
-      code.append("  public Throwable getException() { return null; }\n");
-      code.append("}\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource COLLECTION = new MockJavaResource("java.util.Collection") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package java.util;\n");
-      code.append("public interface Collection<E> {\n");
-      code.append("}\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource DOUBLE = new MockJavaResource("java.lang.Double") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package java.lang;\n");
-      code.append("public class Double extends Number {\n");
-      code.append("  private double value;\n");
-      code.append("  public Double(double value) {\n");
-      code.append("    this.value = value;\n");
-      code.append("  }\n");
-      code.append("  public static boolean isNaN(double d) { return false; }\n");
-      code.append("  public static Double valueOf(double d) { return new Double(d); }\n");
-      code.append("  public double doubleValue() { return value; }\n");
-      code.append("}\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource ENUM = new MockJavaResource("java.lang.Enum") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package java.lang;\n");
-      code.append("import java.io.Serializable;\n");
-      code.append("public abstract class Enum<E extends Enum<E>> implements Serializable {\n");
-      code.append("  protected Enum(String name, int ordinal) {}\n");
-      code.append("  protected static Object createValueOfMap(Enum[] constants) { return null; }\n");
-      code.append("  protected static Enum valueOf(Object map, String name) { return null; }\n");
-      code.append("}\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource ERROR = new MockJavaResource("java.lang.Error") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package java.lang;\n");
-      code.append("public class Error extends Throwable {\n");
-      code.append("}\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource EXCEPTION = new MockJavaResource("java.lang.Exception") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package java.lang;\n");
-      code.append("public class Exception extends Throwable {\n");
-      code.append("}\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource FLOAT = new MockJavaResource("java.lang.Float") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package java.lang;\n");
-      code.append("public class Float extends Number {\n");
-      code.append("  private float value;\n");
-      code.append("  public Float(float value) {\n");
-      code.append("    this.value = value;\n");
-      code.append("  }\n");
-      code.append("  public static Float valueOf(float f) { return new Float(f); }\n");
-      code.append("  public float floatValue() { return value; }\n");
-      code.append("}\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource FOO = new MockJavaResource("test.Foo") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package test;\n");
-      code.append("public class Foo {\n");
-      code.append("  public String value() { return \"Foo\"; }\n");
-      code.append("}\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource INTEGER = new MockJavaResource("java.lang.Integer") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package java.lang;\n");
-      code.append("public class Integer extends Number {\n");
-      code.append("  private int value;\n");
-      code.append("  public Integer(int value) {\n");
-      code.append("    this.value = value;\n");
-      code.append("  }\n");
-      code.append("  public static Integer valueOf(int i) { return new Integer(i); }\n");
-      code.append("  public int intValue() { return value; }\n");
-      code.append("}\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource IS_SERIALIZABLE = new MockJavaResource(
-      "com.google.gwt.user.client.rpc.IsSerializable") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package com.google.gwt.user.client.rpc;\n");
-      code.append("public interface IsSerializable {\n");
-      code.append("}\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource JAVASCRIPTOBJECT = new MockJavaResource(
-      "com.google.gwt.core.client.JavaScriptObject") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package com.google.gwt.core.client;\n");
-      code.append("public class JavaScriptObject {\n");
-      code.append("  public static native JavaScriptObject createObject() /*-{ return {}; }-*/;\n");
-      code.append("  protected JavaScriptObject() { }\n");
-      code.append("  public final String toString() { return \"JavaScriptObject\"; }\n");
-      code.append("}\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource LONG = new MockJavaResource("java.lang.Long") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package java.lang;\n");
-      code.append("public class Long extends Number {\n");
-      code.append("  private long value;\n");
-      code.append("  public Long(long value) {\n");
-      code.append("    this.value = value;\n");
-      code.append("  }\n");
-      code.append("  public static Long valueOf(long l) { return new Long(l); }\n");
-      code.append("  public long longValue() { return value; }\n");
-      code.append("}\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource MAP = new MockJavaResource("java.util.Map") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package java.util;\n");
-      code.append("public interface Map<K,V> { }\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource NO_CLASS_DEF_FOUND_ERROR = new MockJavaResource(
-      "java.lang.NoClassDefFoundError") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package java.lang;\n");
-      code.append("public class NoClassDefFoundError extends Error {\n");
-      code.append("  public NoClassDefFoundError() {}\n");
-      code.append("  public NoClassDefFoundError(String msg) {}\n");
-      code.append("}\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource NUMBER = new MockJavaResource("java.lang.Number") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package java.lang;\n");
-      code.append("public class Number implements java.io.Serializable {\n");
-      code.append("}\n");
-      return code;
-    }
-  };
+  public static final MockJavaResource ANNOTATION =
+      createMockJavaResource("java.lang.annotation.Annotation",
+          "package java.lang.annotation;",
+          "public interface Annotation {",
+          "}");
 
-  public static final MockJavaResource OBJECT = new MockJavaResource("java.lang.Object") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package java.lang;\n");
-      code.append("public class Object {\n");
-      code.append("  private Class<?> ___clazz;");
-      code.append("  public boolean equals(Object that){return this == that;}");
-      code.append("  public int hashCode() { return 0; }\n");
-      code.append("  public String toString() { return \"Object\"; }\n");
-      code.append("  public Object clone() { return this; } ");
-      code.append("  public Class<?> getClass() { return ___clazz; } ");
-      code.append("}\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource SERIALIZABLE = new MockJavaResource("java.io.Serializable") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package java.io;\n");
-      code.append("public interface Serializable { }\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource SHORT = new MockJavaResource("java.lang.Short") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package java.lang;\n");
-      code.append("public class Short extends Number {\n");
-      code.append("  private short value;\n");
-      code.append("  public Short(short value) {\n");
-      code.append("    this.value = value;\n");
-      code.append("  }\n");
-      code.append("  public static Short valueOf(short s) { return new Short(s); }\n");
-      code.append("  public short shortValue() { return value; }\n");
-      code.append("}\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource STRING = new MockJavaResource("java.lang.String") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package java.lang;\n");
-      code.append("import java.io.Serializable;\n");
-      code.append("public final class String implements Serializable {\n");
-      code.append("  public String() { }\n");
-      code.append("  public String(char c) { }\n");
-      code.append("  public String(String s) { }\n");
-      code.append("  public static String _String() { return \"\"; }\n");
-      code.append("  public static String _String(char c) { return \"\" + c; }\n");
-      code.append("  public static String _String(String s) { return s; }\n");
-      code.append("  private static final long serialVersionUID = 0L;\n");
-      code.append("  public char charAt(int index) { return 'a'; }\n");
-      code.append("  public boolean equals(Object obj) { return false; }\n");
-      code.append("  public boolean equalsIgnoreCase(String str) { return false; }\n");
-      code.append("  public int length() { return 0; }\n");
-      code.append("  public static String valueOf(int i) { return \"\" + i; }\n");
-      code.append("  public static String valueOf(char c) { return \"\" + c; }\n");
-      code.append("  public static String valueOf(long l) { return \"\" + l; }\n");
-      code.append("  public int hashCode() { return 0; }\n");
-      code.append("  public String replace(char c1, char c2) { return null; }\n");
-      code.append("  public boolean startsWith(String str) { return false; }\n");
-      code.append("  public String toLowerCase() { return null; }\n");
-      code.append("  public static String valueOf(boolean b) { return null; }\n");
-      code.append("}\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource STRING_BUILDER = new MockJavaResource(
-      "java.lang.StringBuilder") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package java.lang;\n");
-      code.append("public final class StringBuilder {\n");
-      code.append("}\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource SUPPRESS_WARNINGS = new MockJavaResource(
-      "java.lang.SuppressWarnings") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package java.lang;\n");
-      code.append("public @interface SuppressWarnings {\n");
-      code.append("  String[] value();\n");
-      code.append("}\n");
-      return code;
-    }
-  };
-  public static final MockJavaResource THROWABLE = new MockJavaResource("java.lang.Throwable") {
-    @Override
-    public CharSequence getContent() {
-      StringBuilder code = new StringBuilder();
-      code.append("package java.lang;\n");
-      code.append("public class Throwable {\n");
-      code.append("  public String getMessage() { return \"\"; }\n");
-      code.append("  public Throwable getCause() { return null; }\n");
-      code.append("}\n");
-      return code;
-    }
-  };
+  public static final MockJavaResource BAR =
+      createMockJavaResource("test.Bar",
+          "package test;",
+          "public class Bar extends Foo {",
+          "  public String value() { return \"Bar\"; }",
+          "}");
+
+  public static final MockJavaResource BOOLEAN =
+      createMockJavaResource("java.lang.Boolean",
+          "package java.lang;",
+          "public class Boolean {",
+          "  private boolean value;",
+          "  public Boolean(boolean value) {",
+          "    this.value = value;",
+          "  }",
+          "  public static Boolean valueOf(boolean b) { return new Boolean(b); }",
+          "  public boolean booleanValue() { return value; }",
+          "}");
+
+  public static final MockJavaResource BYTE =
+      createMockJavaResource("java.lang.Byte",
+          "package java.lang;",
+          "public class Byte extends Number {",
+          "  private byte value;",
+          "  public Byte(byte value) {",
+          "    this.value = value;",
+          "  }",
+          "  public static Byte valueOf(byte b) { return new Byte(b); }",
+          "  public byte byteValue() { return value; }",
+          "}\n");
+
+  public static final MockJavaResource CHARACTER =
+      createMockJavaResource("java.lang.Character",
+          "package java.lang;",
+          "public class Character {",
+          "  private char value;",
+          "  public Character(char value) {",
+          "    this.value = value;",
+          "  }",
+          "  public static Character valueOf(char c) { return new Character(c); }",
+          "  public char charValue() { return value; }",
+          "}");
+
+  public static final MockJavaResource CLASS =
+      createMockJavaResource("java.lang.Class",
+          "package java.lang;",
+          "public class Class<T> {",
+          "  public String getName() { return null; }",
+          "  public String getSimpleName() { return null; }",
+          "}");
+
+  public static final MockJavaResource CLASS_NOT_FOUND_EXCEPTION =
+      createMockJavaResource("java.lang.ClassNotFoundException",
+          "package java.lang;",
+          "public class ClassNotFoundException extends Exception {",
+          "  public ClassNotFoundException() {}",
+          "  public ClassNotFoundException(String msg) {}",
+          "  public ClassNotFoundException(String msg, Throwable t) {}",
+          "  public Throwable getCause() { return null; }",
+          "  public Throwable getException() { return null; }",
+          "}");
+
+  public static final MockJavaResource COLLECTION =
+      createMockJavaResource("java.util.Collection",
+          "package java.util;",
+          "public interface Collection<E> {",
+          "}");
+
+  public static final MockJavaResource DOUBLE =
+      createMockJavaResource("java.lang.Double",
+          "package java.lang;",
+          "public class Double extends Number {",
+          "  private double value;",
+          "  public Double(double value) {",
+          "    this.value = value;",
+          "  }",
+          "  public static boolean isNaN(double d) { return false; }",
+          "  public static Double valueOf(double d) { return new Double(d); }",
+          "  public double doubleValue() { return value; }",
+          "}");
+
+  public static final MockJavaResource ENUM =
+      createMockJavaResource("java.lang.Enum",
+          "package java.lang;",
+          "import java.io.Serializable;",
+          "public abstract class Enum<E extends Enum<E>> implements Serializable {",
+          "  protected Enum(String name, int ordinal) {}",
+          "  protected static Object createValueOfMap(Enum[] constants) { return null; }",
+          "  protected static Enum valueOf(Object map, String name) { return null; }",
+          "}");
+
+  public static final MockJavaResource ERROR =
+      createMockJavaResource("java.lang.Error",
+          "package java.lang;",
+          "public class Error extends Throwable {",
+          "}");
+
+  public static final MockJavaResource EXCEPTION =
+      createMockJavaResource("java.lang.Exception",
+          "package java.lang;",
+          "public class Exception extends Throwable {",
+          "}");
+
+  public static final MockJavaResource FLOAT =
+      createMockJavaResource("java.lang.Float",
+          "package java.lang;",
+          "public class Float extends Number {",
+          "  private float value;",
+          "  public Float(float value) {",
+          "    this.value = value;",
+          "  }",
+          "  public static Float valueOf(float f) { return new Float(f); }",
+          "  public float floatValue() { return value; }",
+          "}");
+
+  public static final MockJavaResource FOO =
+      createMockJavaResource("test.Foo",
+          "package test;",
+          "public class Foo {",
+          "  public String value() { return \"Foo\"; }",
+          "}");
+
+  public static final MockJavaResource INTEGER =
+      createMockJavaResource("java.lang.Integer",
+          "package java.lang;",
+          "public class Integer extends Number {",
+          "  private int value;",
+          "  public Integer(int value) {",
+          "    this.value = value;",
+          "  }",
+          "  public static Integer valueOf(int i) { return new Integer(i); }",
+          "  public int intValue() { return value; }",
+          "}");
+
+  public static final MockJavaResource IS_SERIALIZABLE =
+      createMockJavaResource(
+      "com.google.gwt.user.client.rpc.IsSerializable",
+      "package com.google.gwt.user.client.rpc;",
+          "public interface IsSerializable {",
+          "}");
+
+  public static final MockJavaResource JAVASCRIPTOBJECT =
+      createMockJavaResource("com.google.gwt.core.client.JavaScriptObject",
+          "package com.google.gwt.core.client;",
+          "public class JavaScriptObject {",
+          "  public static native JavaScriptObject createObject() /*-{ return {}; }-*/;",
+          "  protected JavaScriptObject() { }",
+          "  public final String toString() { return \"JavaScriptObject\"; }",
+          "}");
+
+  public static final MockJavaResource LONG =
+      createMockJavaResource("java.lang.Long",
+          "package java.lang;",
+          "public class Long extends Number {",
+          "  private long value;",
+          "  public Long(long value) {",
+          "    this.value = value;",
+          "  }",
+          "  public static Long valueOf(long l) { return new Long(l); }",
+          "  public long longValue() { return value; }",
+          "}");
+
+  public static final MockJavaResource MAP =
+      createMockJavaResource("java.util.Map",
+          "package java.util;",
+          "public interface Map<K,V> { }");
+
+  public static final MockJavaResource NO_CLASS_DEF_FOUND_ERROR =
+      createMockJavaResource("java.lang.NoClassDefFoundError",
+          "package java.lang;",
+          "public class NoClassDefFoundError extends Error {",
+          "  public NoClassDefFoundError() {}",
+          "  public NoClassDefFoundError(String msg) {}",
+          "}");
+
+  public static final MockJavaResource NUMBER =
+      createMockJavaResource("java.lang.Number",
+          "package java.lang;",
+          "public class Number implements java.io.Serializable {",
+          "}");
+
+  public static final MockJavaResource OBJECT =
+      createMockJavaResource("java.lang.Object",
+          "package java.lang;",
+          "public class Object {",
+          "  private Class<?> ___clazz;",
+          "  public boolean equals(Object that){return this == that;}",
+          "  public int hashCode() { return 0; }",
+          "  public String toString() { return \"Object\"; }",
+          "  public Object clone() { return this; }",
+          "  public Class<?> getClass() { return ___clazz; }",
+          "}");
+
+  public static final MockJavaResource SERIALIZABLE =
+      createMockJavaResource("java.io.Serializable",
+          "package java.io;",
+          "public interface Serializable { }");
+
+  public static final MockJavaResource SHORT =
+      createMockJavaResource("java.lang.Short",
+          "package java.lang;",
+          "public class Short extends Number {",
+          "  private short value;",
+          "  public Short(short value) {",
+          "    this.value = value;",
+          "  }",
+          "  public static Short valueOf(short s) { return new Short(s); }",
+          "  public short shortValue() { return value; }",
+          "}");
+
+  public static final MockJavaResource STRING =
+      createMockJavaResource("java.lang.String",
+          "package java.lang;",
+          "import java.io.Serializable;",
+          "public final class String implements Serializable {",
+          "  public String() { }",
+          "  public String(char c) { }",
+          "  public String(String s) { }",
+          "  public static String _String() { return \"\"; }",
+          "  public static String _String(char c) { return \"\" + c; }",
+          "  public static String _String(String s) { return s; }",
+          "  private static final long serialVersionUID = 0L;",
+          "  public char charAt(int index) { return 'a'; }",
+          "  public boolean equals(Object obj) { return false; }",
+          "  public boolean equalsIgnoreCase(String str) { return false; }",
+          "  public int length() { return 0; }",
+          "  public static String valueOf(int i) { return \"\" + i; }",
+          "  public static String valueOf(char c) { return \"\" + c; }",
+          "  public static String valueOf(long l) { return \"\" + l; }",
+          "  public int hashCode() { return 0; }",
+          "  public String replace(char c1, char c2) { return null; }",
+          "  public boolean startsWith(String str) { return false; }",
+          "  public String toLowerCase() { return null; }",
+          "  public static String valueOf(boolean b) { return null; }",
+          "}");
+
+  public static final MockJavaResource STRING_BUILDER =
+      createMockJavaResource("java.lang.StringBuilder",
+          "package java.lang;",
+          "public final class StringBuilder {",
+          "}");
+
+  public static final MockJavaResource SUPPRESS_WARNINGS =
+      createMockJavaResource("java.lang.SuppressWarnings",
+          "package java.lang;",
+          "public @interface SuppressWarnings {",
+          "  String[] value();",
+          "}");
+
+  public static final MockJavaResource THROWABLE =
+      createMockJavaResource("java.lang.Throwable",
+          "package java.lang;",
+          "public class Throwable {",
+          "  public String getMessage() { return \"\"; }",
+          "  public Throwable getCause() { return null; }",
+          "  public void addSuppressed(Throwable ex) { }",
+          "}");
 
   public static MockJavaResource[] getStandardResources() {
     return new MockJavaResource[]{
-        ANNOTATION, BYTE, BOOLEAN, CHARACTER, CLASS, CLASS_NOT_FOUND_EXCEPTION, COLLECTION, DOUBLE,
-        ENUM, EXCEPTION, ERROR, FLOAT, INTEGER, IS_SERIALIZABLE, JAVASCRIPTOBJECT, LONG, MAP,
-        NO_CLASS_DEF_FOUND_ERROR, NUMBER, OBJECT, SERIALIZABLE, SHORT, STRING, STRING_BUILDER,
-        SUPPRESS_WARNINGS, THROWABLE};
+        AUTOCLOSEABLE, ANNOTATION, BYTE, BOOLEAN, CHARACTER, CLASS, CLASS_NOT_FOUND_EXCEPTION,
+        COLLECTION, DOUBLE, ENUM, EXCEPTION, ERROR, FLOAT, INTEGER, IS_SERIALIZABLE,
+        JAVASCRIPTOBJECT, LONG, MAP, NO_CLASS_DEF_FOUND_ERROR, NUMBER, OBJECT, SERIALIZABLE, SHORT,
+        STRING, STRING_BUILDER, SUPPRESS_WARNINGS, THROWABLE};
+  }
+
+  /**
+   * Creates a new MockJavaResource.
+   */
+  public static MockJavaResource createMockJavaResource(String resourceName,
+      final String... lines) {
+    return new MockJavaResource(resourceName) {
+      @Override
+      public CharSequence getContent() {
+        StringBuilder code = new StringBuilder();
+        for (String line : lines) {
+          code.append(line + "\n");
+        }
+        return code;
+      }
+    };
   }
 }
diff --git a/dev/core/src/com/google/gwt/dev/jjs/JJSOptions.java b/dev/core/src/com/google/gwt/dev/jjs/JJSOptions.java
index 9c1c6dd..b5cb2a0 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/JJSOptions.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/JJSOptions.java
@@ -31,6 +31,7 @@
 import com.google.gwt.dev.util.arg.OptionRemoveDuplicateFunctions;
 import com.google.gwt.dev.util.arg.OptionRunAsyncEnabled;
 import com.google.gwt.dev.util.arg.OptionScriptStyle;
+import com.google.gwt.dev.util.arg.OptionSource;
 import com.google.gwt.dev.util.arg.OptionSoycDetailed;
 import com.google.gwt.dev.util.arg.OptionSoycEnabled;
 import com.google.gwt.dev.util.arg.OptionSoycHtmlDisabled;
@@ -44,6 +45,6 @@
     OptionEnableAssertions, OptionInlineLiteralParameters, OptionOptimizeDataflow,
     OptionRunAsyncEnabled, OptionScriptStyle, OptionSoycEnabled, OptionSoycDetailed,
     OptionOptimizePrecompile, OptionOrdinalizeEnums, OptionRemoveDuplicateFunctions, OptionStrict,
-    OptionSoycHtmlDisabled, OptionEnableClosureCompiler, OptionFragmentsMerge, OptionFragmentCount {
-
+    OptionSoycHtmlDisabled, OptionEnableClosureCompiler, OptionFragmentsMerge, OptionFragmentCount,
+    OptionSource {
 }
diff --git a/dev/core/src/com/google/gwt/dev/jjs/JJSOptionsImpl.java b/dev/core/src/com/google/gwt/dev/jjs/JJSOptionsImpl.java
index d853cf6..9435635 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/JJSOptionsImpl.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/JJSOptionsImpl.java
@@ -16,6 +16,8 @@
 package com.google.gwt.dev.jjs;
 
 import com.google.gwt.dev.util.arg.OptionOptimize;
+import com.google.gwt.dev.util.arg.OptionSource;
+import com.google.gwt.dev.util.arg.SourceLevel;
 
 import java.io.Serializable;
 
@@ -45,6 +47,7 @@
   private boolean soycExtra = false;
   private boolean soycHtmlDisabled = false;
   private boolean strict = false;
+  private SourceLevel sourceLevel = OptionSource.DEFAULT_SOURCE_LEVEL;
 
   public JJSOptionsImpl() {
   }
@@ -74,6 +77,7 @@
     setSoycExtra(other.isSoycExtra());
     setSoycHtmlDisabled(other.isSoycHtmlDisabled());
     setStrict(other.isStrict());
+    setSourceLevel(other.getSourceLevel());
   }
 
   @Override
@@ -97,6 +101,10 @@
   }
 
   @Override
+  public SourceLevel getSourceLevel() {
+    return sourceLevel;
+  }
+
   @Deprecated
   public boolean isAggressivelyOptimize() {
     return aggressivelyOptimize;
@@ -248,6 +256,11 @@
   }
 
   @Override
+  public void setSourceLevel(SourceLevel sourceLevel) {
+    this.sourceLevel = sourceLevel;
+  }
+
+  @Override
   public void setSoycEnabled(boolean enabled) {
     soycEnabled = enabled;
   }
diff --git a/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerSource.java b/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerSource.java
new file mode 100644
index 0000000..927f7e5
--- /dev/null
+++ b/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerSource.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.dev.util.arg;
+
+import com.google.gwt.thirdparty.guava.common.base.Joiner;
+import com.google.gwt.thirdparty.guava.common.collect.ImmutableMap;
+import com.google.gwt.util.tools.ArgHandlerString;
+
+import java.util.Map;
+
+/**
+ * Set the Java source level compatibility.
+ */
+public class ArgHandlerSource extends ArgHandlerString {
+  private static final Map<String, SourceLevel> sourceLevelsByString;
+
+  static {
+    ImmutableMap.Builder<String, SourceLevel> builder = ImmutableMap.<String, SourceLevel>builder();
+    for (SourceLevel sourceLevel : SourceLevel.values()) {
+      builder.put(sourceLevel.getStringValue(), sourceLevel);
+      builder.put(sourceLevel.getAltStringValue(), sourceLevel);
+    }
+    sourceLevelsByString = builder.build();
+  }
+
+  private final OptionSource options;
+
+  public ArgHandlerSource(OptionSource options) {
+    this.options = options;
+  }
+
+  @Override
+  public String[] getDefaultArgs() {
+    return new String[]{getTag(), OptionSource.DEFAULT_SOURCE_LEVEL.getStringValue()};
+  }
+
+  @Override
+  public String getPurpose() {
+    return "Specifies Java source level (defaults to " + OptionSource.DEFAULT_SOURCE_LEVEL + ")";
+  }
+
+  @Override
+  public String getTag() {
+    return "-sourceLevel";
+  }
+
+  @Override
+  public String[] getTagArgs() {
+    return new String[]{"[" + Joiner.on(",").join(SourceLevel.values()) + "]"};
+  }
+
+  @Override
+  public boolean setString(String value) {
+    SourceLevel level = sourceLevelsByString.get(value);
+    if (value == null) {
+      System.err.println("Source level must be one of [" +
+          Joiner.on(",").join(SourceLevel.values()) + "].");
+      return false;
+    }
+    options.setSourceLevel(level);
+    return true;
+  }
+}
diff --git a/dev/core/src/com/google/gwt/dev/util/arg/OptionSource.java b/dev/core/src/com/google/gwt/dev/util/arg/OptionSource.java
new file mode 100644
index 0000000..15f238f
--- /dev/null
+++ b/dev/core/src/com/google/gwt/dev/util/arg/OptionSource.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.dev.util.arg;
+
+/**
+ * An option that can indicates the Java source level compatibility.
+ */
+public interface OptionSource {
+
+  static final SourceLevel DEFAULT_SOURCE_LEVEL = SourceLevel.JAVA6;
+
+  SourceLevel getSourceLevel();
+
+  void setSourceLevel(SourceLevel level);
+}
diff --git a/dev/core/src/com/google/gwt/dev/util/arg/SourceLevel.java b/dev/core/src/com/google/gwt/dev/util/arg/SourceLevel.java
new file mode 100644
index 0000000..63c2fc2
--- /dev/null
+++ b/dev/core/src/com/google/gwt/dev/util/arg/SourceLevel.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.dev.util.arg;
+
+/**
+ * Java source level compatibility constants.
+ * Java versions range from 1.0 to 1.7.
+ * Versions 1.5, 1.6 and 1.7 are also referred as 5, 6 and 7 respectively.
+ *
+ * Both names can be used indistinctly.
+ */
+public enum SourceLevel {
+  JAVA6("1.6", "6"),
+  JAVA7("1.7", "7");
+
+  private final String stringValue;
+  private final String altStringValue;
+
+  SourceLevel(String stringValue, String altStringValue) {
+    this.stringValue = stringValue;
+    this.altStringValue = altStringValue;
+  }
+
+  /**
+   * Returns a string value representation for the source level.
+   */
+  public String getStringValue() {
+    return stringValue;
+  }
+
+  /**
+   * Returns an alternate string value representation for the source level.
+   */
+  public String getAltStringValue() {
+    return altStringValue;
+  }
+
+  @Override
+  public String toString() {
+    return stringValue;
+  }
+}
diff --git a/dev/core/test/com/google/gwt/dev/CompilerTest.java b/dev/core/test/com/google/gwt/dev/CompilerTest.java
index 2c47e86..fc31312 100644
--- a/dev/core/test/com/google/gwt/dev/CompilerTest.java
+++ b/dev/core/test/com/google/gwt/dev/CompilerTest.java
@@ -18,6 +18,7 @@
 import com.google.gwt.core.ext.TreeLogger;
 import com.google.gwt.dev.Compiler.CompilerOptionsImpl;
 import com.google.gwt.dev.jjs.JsOutputOption;
+import com.google.gwt.dev.util.arg.SourceLevel;
 
 import java.io.File;
 
@@ -37,7 +38,7 @@
     assertProcessSuccess(argProcessor, "-logLevel", "DEBUG", "-style",
         "PRETTY", "-ea", "-XdisableAggressiveOptimization", "-gen", "myGen",
         "-war", "myWar", "-workDir", "myWork", "-extra", "myExtra",
-        "-localWorkers", "2", "c.g.g.h.H", "my.Module");
+        "-localWorkers", "2", "-sourceLevel", "1.7", "c.g.g.h.H", "my.Module");
 
     assertEquals(new File("myGen").getAbsoluteFile(),
         options.getGenDir().getAbsoluteFile());
@@ -56,6 +57,8 @@
     assertFalse(options.shouldOrdinalizeEnums());
     assertFalse(options.shouldRemoveDuplicateFunctions());
 
+    assertEquals(SourceLevel.JAVA7, options.getSourceLevel());
+
     assertEquals(2, options.getModuleNames().size());
     assertEquals("c.g.g.h.H", options.getModuleNames().get(0));
     assertEquals("my.Module", options.getModuleNames().get(1));
@@ -87,5 +90,7 @@
 
   public void testForbiddenArgs() {
     assertProcessFailure(argProcessor, "-out", "www");
+    assertProcessFailure(argProcessor, "-sourceLevel", "ssss");
+    assertProcessFailure(argProcessor, "-sourceLevel", "1.5");
   }
 }
diff --git a/dev/core/test/com/google/gwt/dev/javac/CompilationStateTestBase.java b/dev/core/test/com/google/gwt/dev/javac/CompilationStateTestBase.java
index 8d74ce9..d909f1c 100644
--- a/dev/core/test/com/google/gwt/dev/javac/CompilationStateTestBase.java
+++ b/dev/core/test/com/google/gwt/dev/javac/CompilationStateTestBase.java
@@ -22,6 +22,7 @@
 import com.google.gwt.dev.javac.testing.impl.MockResourceOracle;
 import com.google.gwt.dev.resource.Resource;
 import com.google.gwt.dev.util.Util;
+import com.google.gwt.dev.util.arg.OptionSource;
 import com.google.gwt.dev.util.log.AbstractTreeLogger;
 import com.google.gwt.dev.util.log.PrintWriterTreeLogger;
 
@@ -123,7 +124,8 @@
 
   protected void rebuildCompilationState() {
     try {
-      state = isolatedBuilder.doBuildFrom(createTreeLogger(), oracle.getResources(), false);
+      state = isolatedBuilder.doBuildFrom(createTreeLogger(), oracle.getResources(), false,
+          OptionSource.DEFAULT_SOURCE_LEVEL);
     } catch (UnableToCompleteException e) {
       throw new RuntimeException(e);
     }
diff --git a/dev/core/test/com/google/gwt/dev/javac/JavaCompilationSuite.java b/dev/core/test/com/google/gwt/dev/javac/JavaCompilationSuite.java
index 4073095..ff00bf7 100644
--- a/dev/core/test/com/google/gwt/dev/javac/JavaCompilationSuite.java
+++ b/dev/core/test/com/google/gwt/dev/javac/JavaCompilationSuite.java
@@ -50,6 +50,7 @@
     suite.addTestSuite(JavaSourceParserTest.class);
     suite.addTestSuite(JdtBehaviorTest.class);
     suite.addTestSuite(JdtCompilerTest.class);
+    suite.addTestSuite(JdtJava7Test.class);
     suite.addTestSuite(JsniCheckerTest.class);
     suite.addTestSuite(JsniCollectorTest.class);
     suite.addTestSuite(JSORestrictionsTest.class);
diff --git a/dev/core/test/com/google/gwt/dev/javac/JdtBehaviorTest.java b/dev/core/test/com/google/gwt/dev/javac/JdtBehaviorTest.java
index bfbec85..0be5bac 100644
--- a/dev/core/test/com/google/gwt/dev/javac/JdtBehaviorTest.java
+++ b/dev/core/test/com/google/gwt/dev/javac/JdtBehaviorTest.java
@@ -60,7 +60,7 @@
     public CompilerImpl(INameEnvironment environment,
         ICompilerRequestor requestor) {
       super(environment, DefaultErrorHandlingPolicies.proceedWithAllProblems(),
-          JdtCompiler.getCompilerOptions(), requestor,
+          JdtCompiler.getStandardCompilerOptions(), requestor,
           new DefaultProblemFactory(Locale.getDefault()));
     }
   }
diff --git a/dev/core/test/com/google/gwt/dev/javac/JdtJava7Test.java b/dev/core/test/com/google/gwt/dev/javac/JdtJava7Test.java
new file mode 100644
index 0000000..6aa42b8
--- /dev/null
+++ b/dev/core/test/com/google/gwt/dev/javac/JdtJava7Test.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.dev.javac;
+
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.dev.javac.testing.impl.Java7MockResources;
+import com.google.gwt.dev.javac.testing.impl.JavaResourceBase;
+import com.google.gwt.dev.resource.Resource;
+import com.google.gwt.dev.util.Strings;
+import com.google.gwt.dev.util.arg.SourceLevel;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jdt.core.compiler.CategorizedProblem;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * Test class for language features introduced in Java 7.
+ *
+ * Only tests that the JDT accepts and compiles the new syntax..
+ */
+public class JdtJava7Test extends TestCase {
+
+  static void assertUnitHasErrors(CompilationUnit unit, int numErrors) {
+    assertTrue(unit.isError());
+    assertEquals(numErrors, unit.getProblems().length);
+  }
+
+  static void assertUnitsCompiled(Collection<CompilationUnit> units) {
+    for (CompilationUnit unit : units) {
+      if (unit.isError()) {
+        String[] messages = new String[unit.getProblems().length];
+        int i = 0;
+        for (CategorizedProblem pb : unit.getProblems()) {
+          messages[i] = pb.getMessage();
+        }
+        fail(Strings.join(messages, "\n"));
+      }
+      assertTrue(unit.getCompiledClasses().size() > 0);
+    }
+  }
+
+  public void testCompileNewStyleLiterals() throws Exception {
+    List<CompilationUnitBuilder> builders = new ArrayList<CompilationUnitBuilder>();
+    addAll(builders, JavaResourceBase.getStandardResources());
+    addAll(builders, Java7MockResources.LIST_T, Java7MockResources.ARRAYLIST_T,
+        Java7MockResources.NEW_INTEGER_LITERALS_TEST);
+    Collection<CompilationUnit> units = compile(TreeLogger.NULL, builders);
+    assertUnitsCompiled(units);
+  }
+
+  public void testCompileSwitchWithStrings() throws Exception {
+    List<CompilationUnitBuilder> builders = new ArrayList<CompilationUnitBuilder>();
+    addAll(builders, JavaResourceBase.getStandardResources());
+    addAll(builders, Java7MockResources.LIST_T, Java7MockResources.ARRAYLIST_T,
+        Java7MockResources.SWITCH_ON_STRINGS_TEST);
+    Collection<CompilationUnit> units = compile(TreeLogger.NULL, builders);
+    assertUnitsCompiled(units);
+  }
+
+  public void testCompileDiamondOperator() throws Exception {
+    List<CompilationUnitBuilder> builders = new ArrayList<CompilationUnitBuilder>();
+    addAll(builders, JavaResourceBase.getStandardResources());
+    addAll(builders, Java7MockResources.LIST_T, Java7MockResources.ARRAYLIST_T,
+        Java7MockResources.DIAMOND_OPERATOR_TEST);
+    Collection<CompilationUnit> units = compile(TreeLogger.NULL, builders);
+    assertUnitsCompiled(units);
+  }
+
+  public void testCompileTryWithResources() throws Exception {
+    List<CompilationUnitBuilder> builders = new ArrayList<CompilationUnitBuilder>();
+    addAll(builders, JavaResourceBase.getStandardResources());
+    addAll(builders,
+        Java7MockResources.TEST_RESOURCE, Java7MockResources.TRY_WITH_RESOURCES_TEST);
+    Collection<CompilationUnit> units = compile(TreeLogger.NULL, builders);
+    assertUnitsCompiled(units);
+  }
+
+  public void testCompileMultiExceptions() throws Exception {
+    List<CompilationUnitBuilder> builders = new ArrayList<CompilationUnitBuilder>();
+    addAll(builders, JavaResourceBase.getStandardResources());
+    addAll(builders, Java7MockResources.EXCEPTION1, Java7MockResources.EXCEPTION2,
+        Java7MockResources.MULTI_EXCEPTION_TEST);
+    Collection<CompilationUnit> units = compile(TreeLogger.NULL, builders);
+    assertUnitsCompiled(units);
+  }
+
+  private void addAll(Collection<CompilationUnitBuilder> units,
+                      Resource... sourceFiles) {
+    for (Resource sourceFile : sourceFiles) {
+      units.add(CompilationUnitBuilder.create(sourceFile));
+    }
+  }
+
+  private List<CompilationUnit> compile(TreeLogger logger,
+      Collection<CompilationUnitBuilder> builders) throws UnableToCompleteException {
+    return JdtCompiler.compile(logger, builders, SourceLevel.JAVA7);
+  }
+}
diff --git a/dev/core/test/com/google/gwt/dev/jjs/impl/CodeSplitter2Test.java b/dev/core/test/com/google/gwt/dev/jjs/impl/CodeSplitter2Test.java
index 105b169..9d64fa5 100644
--- a/dev/core/test/com/google/gwt/dev/jjs/impl/CodeSplitter2Test.java
+++ b/dev/core/test/com/google/gwt/dev/jjs/impl/CodeSplitter2Test.java
@@ -261,7 +261,7 @@
     addBuiltinClasses(sourceOracle);
     CompilationState state =
         CompilationStateBuilder.buildFrom(logger, sourceOracle.getResources(),
-            getAdditionalTypeProviderDelegate());
+            getAdditionalTypeProviderDelegate(), sourceLevel);
     jProgram =
         JavaAstConstructor.construct(logger, state, "test.EntryPoint",
             "com.google.gwt.lang.Exceptions");
@@ -292,7 +292,7 @@
     addBuiltinClasses(sourceOracle);
     CompilationState state =
         CompilationStateBuilder.buildFrom(logger, sourceOracle.getResources(),
-            getAdditionalTypeProviderDelegate());
+            getAdditionalTypeProviderDelegate(), sourceLevel);
     jProgram =
         JavaAstConstructor.construct(logger, state, "test.EntryPoint",
             "com.google.gwt.lang.Exceptions");
diff --git a/dev/core/test/com/google/gwt/dev/jjs/impl/JJSTestBase.java b/dev/core/test/com/google/gwt/dev/jjs/impl/JJSTestBase.java
index 28b104b..747ff4a 100644
--- a/dev/core/test/com/google/gwt/dev/jjs/impl/JJSTestBase.java
+++ b/dev/core/test/com/google/gwt/dev/jjs/impl/JJSTestBase.java
@@ -31,6 +31,8 @@
 import com.google.gwt.dev.jjs.ast.JProgram;
 import com.google.gwt.dev.jjs.ast.JVisitor;
 import com.google.gwt.dev.util.Strings;
+import com.google.gwt.dev.util.arg.OptionSource;
+import com.google.gwt.dev.util.arg.SourceLevel;
 import com.google.gwt.dev.util.log.AbstractTreeLogger;
 import com.google.gwt.dev.util.log.PrintWriterTreeLogger;
 
@@ -237,7 +239,7 @@
     addBuiltinClasses(sourceOracle);
     CompilationState state =
         CompilationStateBuilder.buildFrom(logger, sourceOracle.getResources(),
-            getAdditionalTypeProviderDelegate());
+            getAdditionalTypeProviderDelegate(), sourceLevel);
     JProgram program =
         JavaAstConstructor.construct(logger, state, "test.EntryPoint",
             "com.google.gwt.lang.Exceptions");
@@ -282,4 +284,9 @@
   protected AdditionalTypeProviderDelegate getAdditionalTypeProviderDelegate() {
     return null;
   }
+
+  /**
+   * Java source level compatibility option.
+   */
+  protected SourceLevel sourceLevel = OptionSource.DEFAULT_SOURCE_LEVEL;
 }
diff --git a/dev/core/test/com/google/gwt/dev/jjs/impl/Java7AstTest.java b/dev/core/test/com/google/gwt/dev/jjs/impl/Java7AstTest.java
new file mode 100644
index 0000000..5e261ea
--- /dev/null
+++ b/dev/core/test/com/google/gwt/dev/jjs/impl/Java7AstTest.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.dev.jjs.impl;
+
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.dev.javac.testing.impl.Java7MockResources;
+import com.google.gwt.dev.javac.testing.impl.JavaResourceBase;
+import com.google.gwt.dev.jjs.ast.JBlock;
+import com.google.gwt.dev.jjs.ast.JExpression;
+import com.google.gwt.dev.jjs.ast.JMethod;
+import com.google.gwt.dev.jjs.ast.JMethodBody;
+import com.google.gwt.dev.jjs.ast.JProgram;
+import com.google.gwt.dev.jjs.ast.JReturnStatement;
+import com.google.gwt.dev.resource.Resource;
+import com.google.gwt.dev.util.arg.SourceLevel;
+
+/**
+ * Tests that {@link GwtAstBuilder} correctly builds the AST for features introduced in Java 7.
+ */
+public class Java7AstTest extends JJSTestBase {
+
+  @Override
+  public void setUp() {
+    sourceLevel = SourceLevel.JAVA7;
+    addAll(Java7MockResources.LIST_T, Java7MockResources.ARRAYLIST_T);
+  }
+
+  public void testCompileNewStyleLiterals() throws Exception {
+    assertEqualExpression("int", "10000000", "1_000_0000");
+    assertEqualExpression("int", "5", "0b101");
+    assertEqualExpression("int", "6", "0B110");
+  }
+
+  public void testCompileStringSwitch() throws Exception {
+    assertEqualBlock(
+        "String input = \"\";" +
+        "switch (input) {" +
+        "  case \"AA\": break;" +
+        "  case \"BB\": break;" +
+        "}",
+        "String input = \"\";" +
+        "switch (input) {" +
+        "  case \"AA\": break;" +
+        "  case \"BB\": break;" +
+        "}");
+  }
+
+
+  public void testCompileDiamondOperator() throws Exception {
+    addSnippetImport("com.google.gwt.List");
+    addSnippetImport("com.google.gwt.ArrayList");
+    assertEqualBlock(
+        "List l = new ArrayList();",
+        "List<String> l = new ArrayList<>();");
+  }
+
+  private void addAll(Resource... sourceFiles) {
+    for (Resource sourceFile : sourceFiles) {
+      sourceOracle.addOrReplace(sourceFile);
+    }
+  }
+
+  private void assertEqualExpression(String type, String expected, String expression)
+      throws UnableToCompleteException {
+    JExpression testExpresssion = getExpression(type, expression);
+    assertEquals(expected, testExpresssion.toSource());
+  }
+
+  private JExpression getExpression(String type, String expression)
+      throws UnableToCompleteException {
+    JProgram program = compileSnippet(type, "return " + expression + ";");
+    JMethod mainMethod = findMainMethod(program);
+    JMethodBody body = (JMethodBody) mainMethod.getBody();
+    JReturnStatement returnStmt = (JReturnStatement) body.getStatements().get(0);
+    return returnStmt.getExpr();
+  }
+
+  private void assertEqualBlock(String expected, String input)
+      throws UnableToCompleteException {
+    JBlock testExpression = getStatement(input);
+    assertEquals(formatSource("{ " + expected + "}"),
+        formatSource(testExpression.toSource()));
+  }
+
+  /**
+   * Removes most whitespace while still leaving one space separating words.
+   *
+   * Used to make the assertEquals ignore whitespace (mostly) while still retaining meaningful
+   * output when the test fails.
+   */
+  private String formatSource(String source) {
+    return source.replaceAll("\\s+", " ") // substitutes multiple whitespaces into one.
+      .replaceAll("\\s([\\p{Punct}&&[^$]])", "$1")  // removes whitespace preceding symbols
+                                                    // (except $ which can be part of an identifier)
+      .replaceAll("([\\p{Punct}&&[^$]])\\s", "$1"); // removes whitespace succeeding symbols.
+  }
+
+  private JBlock getStatement(String statement)
+      throws UnableToCompleteException {
+    JProgram program = compileSnippet("void", statement);
+    JMethod mainMethod = findMainMethod(program);
+    JMethodBody body = (JMethodBody) mainMethod.getBody();
+    return body.getBlock();
+  }
+
+}
diff --git a/user/src/com/google/gwt/junit/JUnitShell.java b/user/src/com/google/gwt/junit/JUnitShell.java
index b442959..0732d69 100644
--- a/user/src/com/google/gwt/junit/JUnitShell.java
+++ b/user/src/com/google/gwt/junit/JUnitShell.java
@@ -25,6 +25,7 @@
 import com.google.gwt.core.shared.SerializableThrowable;
 import com.google.gwt.dev.ArgProcessorBase;
 import com.google.gwt.dev.Compiler;
+import com.google.gwt.dev.CompilerOptions;
 import com.google.gwt.dev.DevMode;
 import com.google.gwt.dev.cfg.BindingProperty;
 import com.google.gwt.dev.cfg.ModuleDef;
@@ -55,6 +56,7 @@
 import com.google.gwt.dev.util.arg.ArgHandlerMaxPermsPerPrecompile;
 import com.google.gwt.dev.util.arg.ArgHandlerOptimize;
 import com.google.gwt.dev.util.arg.ArgHandlerScriptStyle;
+import com.google.gwt.dev.util.arg.ArgHandlerSource;
 import com.google.gwt.dev.util.arg.ArgHandlerWarDir;
 import com.google.gwt.dev.util.arg.ArgHandlerWorkDirOptional;
 import com.google.gwt.junit.JUnitMessageQueue.ClientStatus;
@@ -279,6 +281,8 @@
       registerHandler(new ArgHandlerDeployDir(options));
       registerHandler(new ArgHandlerExtraDir(options));
       registerHandler(new ArgHandlerWorkDirOptional(options));
+      registerHandler(new ArgHandlerSource(options));
+
       // DISABLE: ArgHandlerModuleName
 
       /*
@@ -646,6 +650,18 @@
   }
 
   /**
+   * Get the compiler options
+   *
+   * @return the the compiler options that have been set.
+   */
+  public static CompilerOptions getCompilerOptions() {
+    if (unitTestShell == null) {
+      return null;
+    }
+    return unitTestShell.options;
+  }
+
+  /**
    * Checks if a testCase should not be executed. Currently, a test is either
    * executed on all clients (mentioned in this test) or on no clients.
    * 
@@ -1312,7 +1328,8 @@
     if (!sameTest) {
       currentModule = compileStrategy.maybeCompileModule(moduleName,
           syntheticModuleName, strategy, batchingStrategy, getTopLogger());
-      currentCompilationState = currentModule.getCompilationState(getTopLogger(), true);
+      currentCompilationState = currentModule.getCompilationState(getTopLogger(), true,
+          options.getSourceLevel());
     }
     assert (currentModule != null);
 
diff --git a/user/test-super/com/google/gwt/dev/jjs/super/com/google/gwt/dev/jjs/test/Java7Test.java b/user/test-super/com/google/gwt/dev/jjs/super/com/google/gwt/dev/jjs/test/Java7Test.java
new file mode 100644
index 0000000..f849634
--- /dev/null
+++ b/user/test-super/com/google/gwt/dev/jjs/super/com/google/gwt/dev/jjs/test/Java7Test.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2013 Google Inc.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.dev.jjs.test;
+
+import com.google.gwt.junit.client.GWTTestCase;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Tests Java 7 features. It is super sourced so that gwt can be compiles under Java 6.
+ *
+ * IMPORTANT: For each test here there must exist the corresponding method in the non super sourced
+ * version.
+ *
+ * Eventually this test will graduate and not be super sourced.
+ */
+public class Java7Test extends GWTTestCase {
+
+  @Override
+  public String getModuleName() {
+    return "com.google.gwt.dev.jjs.Java7Test";
+  }
+
+  // new style class literals
+// CHECKSTYLE:OFF
+  int million = 1_000_000;
+
+  int five = 0b101;
+// CHECKSTYLE:ON
+
+  public void testNewStyleLiterals() {
+    assertEquals(1000000, million);
+    assertEquals(5, five);
+  }
+
+  public void testSwitchOnString() {
+
+    String s = "AA";
+    int result = -1;
+    switch (s) {
+      case "BB":
+        result = 0;
+        break;
+      case "CC":
+      case "AA":
+        result = 1;
+        break;
+    }
+    assertEquals(1, result);
+  }
+}
diff --git a/user/test/com/google/gwt/dev/jjs/CompilerSuite.java b/user/test/com/google/gwt/dev/jjs/CompilerSuite.java
index 98d00fb..40a30df 100644
--- a/user/test/com/google/gwt/dev/jjs/CompilerSuite.java
+++ b/user/test/com/google/gwt/dev/jjs/CompilerSuite.java
@@ -34,6 +34,7 @@
 import com.google.gwt.dev.jjs.test.InnerClassTest;
 import com.google.gwt.dev.jjs.test.InnerOuterSuperTest;
 import com.google.gwt.dev.jjs.test.JStaticEvalTest;
+import com.google.gwt.dev.jjs.test.Java7Test;
 import com.google.gwt.dev.jjs.test.JavaAccessFromJavaScriptTest;
 import com.google.gwt.dev.jjs.test.JsStaticEvalTest;
 import com.google.gwt.dev.jjs.test.JsniConstructorTest;
@@ -81,6 +82,7 @@
     suite.addTestSuite(InitialLoadSequenceTest.class);
     suite.addTestSuite(InnerClassTest.class);
     suite.addTestSuite(InnerOuterSuperTest.class);
+    suite.addTestSuite(Java7Test.class);
     suite.addTestSuite(JavaAccessFromJavaScriptTest.class);
     suite.addTestSuite(JsniConstructorTest.class);
     suite.addTestSuite(JsoTest.class);
diff --git a/user/test/com/google/gwt/dev/jjs/Java7Test.gwt.xml b/user/test/com/google/gwt/dev/jjs/Java7Test.gwt.xml
new file mode 100644
index 0000000..f6c0c9e
--- /dev/null
+++ b/user/test/com/google/gwt/dev/jjs/Java7Test.gwt.xml
@@ -0,0 +1,19 @@
+<!--                                                                        -->
+<!-- Copyright 2013 Google Inc.                                             -->
+<!-- Licensed under the Apache License, Version 2.0 (the "License"); you    -->
+<!-- may not use this file except in compliance with the License. You may   -->
+<!-- may obtain a copy of the License at                                    -->
+<!--                                                                        -->
+<!-- http://www.apache.org/licenses/LICENSE-2.0                             -->
+<!--                                                                        -->
+<!-- Unless required by applicable law or agreed to in writing, software    -->
+<!-- distributed under the License is distributed on an "AS IS" BASIS,      -->
+<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        -->
+<!-- implied. License for the specific language governing permissions and   -->
+<!-- limitations under the License.                                         -->
+
+<!-- Contains tests for breaking out of the client source path  -->
+<module>
+  <inherits name="com.google.gwt.core.Core" />
+  <super-source path='super' />
+</module>
\ No newline at end of file
diff --git a/user/test/com/google/gwt/dev/jjs/test/Java7Test.java b/user/test/com/google/gwt/dev/jjs/test/Java7Test.java
new file mode 100644
index 0000000..2ef1c47
--- /dev/null
+++ b/user/test/com/google/gwt/dev/jjs/test/Java7Test.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.dev.jjs.test;
+
+import com.google.gwt.dev.util.arg.SourceLevel;
+import com.google.gwt.junit.JUnitShell;
+import com.google.gwt.junit.client.GWTTestCase;
+
+/**
+ * Dummy test case. Java7Test is super sourced so that GWT can be compiled by Java 6.
+ *
+ * NOTE: Make sure this class has the same test methods of its supersourced variant.
+ */
+public class Java7Test extends GWTTestCase {
+
+  @Override
+  public String getModuleName() {
+    return "com.google.gwt.dev.jjs.Java7Test";
+  }
+
+  @Override
+  public void runTest() throws Throwable {
+    // Only run these tests if -sourceLevel 7 (or greated) is enabled.
+    if (JUnitShell.getCompilerOptions().getSourceLevel()
+        .compareTo(SourceLevel.JAVA7) >= 0) {
+      super.runTest();
+    }
+  }
+
+  public void testNewStyleLiterals() {
+    // Make sure we are using the right Java7Test if the source compatibility level is set to Java 7
+    // or above.
+    assertFalse((JUnitShell.getCompilerOptions().getSourceLevel()
+        .compareTo(SourceLevel.JAVA7) >= 0));
+  }
+
+  public void testSwitchOnString() {
+  }
+}