test/tools/javac/diags/Example.java

changeset 842
3da26790ccb7
parent 689
77cc34d5e548
child 893
8f0dcb9499db
     1.1 --- a/test/tools/javac/diags/Example.java	Wed Jan 26 11:20:19 2011 -0800
     1.2 +++ b/test/tools/javac/diags/Example.java	Wed Jan 26 13:45:25 2011 -0800
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -168,7 +168,7 @@
    1.11          try {
    1.12              run(null, keys, true, verbose);
    1.13          } catch (IOException e) {
    1.14 -            e.printStackTrace();
    1.15 +            e.printStackTrace(System.err);
    1.16          }
    1.17          return keys;
    1.18      }
    1.19 @@ -293,10 +293,15 @@
    1.20      }
    1.21  
    1.22      abstract static class Compiler {
    1.23 -        static Compiler getCompiler(List<String> opts, boolean verbose) {
    1.24 +        interface Factory {
    1.25 +            Compiler getCompiler(List<String> opts, boolean verbose);
    1.26 +        }
    1.27 +
    1.28 +        static class DefaultFactory implements Factory {
    1.29 +            public Compiler getCompiler(List<String> opts, boolean verbose) {
    1.30              String first;
    1.31              String[] rest;
    1.32 -            if (opts == null || opts.size() == 0) {
    1.33 +                if (opts == null || opts.isEmpty()) {
    1.34                  first = null;
    1.35                  rest = new String[0];
    1.36              } else {
    1.37 @@ -311,6 +316,16 @@
    1.38                  return new BackdoorCompiler(verbose);
    1.39              else
    1.40                  throw new IllegalArgumentException(first);
    1.41 +                }
    1.42 +        }
    1.43 +
    1.44 +        static Factory factory;
    1.45 +
    1.46 +        static Compiler getCompiler(List<String> opts, boolean verbose) {
    1.47 +            if (factory == null)
    1.48 +                factory = new DefaultFactory();
    1.49 +
    1.50 +            return factory.getCompiler(opts, verbose);
    1.51          }
    1.52  
    1.53          protected Compiler(boolean verbose) {

mercurial