Merge remote-tracking branch 'origin/master' into YaSp 72/16572/1
Vincent COUVERT [Tue, 2 Jun 2015 08:33:59 +0000 (10:33 +0200)]
Conflicts:
scilab/modules/fftw/src/c/fftw_utilities.c
scilab/modules/overloading/macros/%hm_prod.sci
scilab/modules/overloading/macros/%hm_sum.sci

Change-Id: I82b54e5c917e07e8637b561ddec9949fd0bcb038

1  2 
scilab/modules/external_objects_java/src/java/org/scilab/modules/external_objects_java/ScilabJavaCompiler.java

@@@ -32,7 -32,6 +32,7 @@@ import java.util.Locale
  import java.util.ServiceLoader;
  import java.util.logging.Level;
  
 +import javax.swing.SwingUtilities;
  import javax.tools.Diagnostic;
  import javax.tools.DiagnosticCollector;
  import javax.tools.FileObject;
@@@ -117,29 -116,7 +117,29 @@@ public class ScilabJavaCompiler 
       * @return an integer corresponding to the compiled and loaded class.
       */
      public static int compileCode(String className, String[] code) throws ScilabJavaException {
 -        findCompiler();
 +        if (SwingUtilities.isEventDispatchThread()) {
 +            findCompiler();
 +        } else {
 +            try {
 +                SwingUtilities.invokeAndWait(new Runnable() {
 +                    @Override
 +                    public void run() {
 +                        try {
 +                            findCompiler();
 +                        } catch (ScilabJavaException e) {
 +                            // TODO Auto-generated catch block
 +                            e.printStackTrace();
 +                        }
 +                    }
 +                });
 +            } catch (InvocationTargetException e) {
 +                // TODO Auto-generated catch block
 +                e.printStackTrace();
 +            } catch (InterruptedException e) {
 +                // TODO Auto-generated catch block
 +                e.printStackTrace();
 +            }
 +        }
  
          DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>();
          StandardJavaFileManager stdFileManager = compiler.getStandardFileManager(null, Locale.getDefault(), null);
          int cpt = 1;
          buffer.append("----------\n");
          for (Diagnostic <? extends JavaFileObject > d : diagnostics.getDiagnostics()) {
-             buffer.append(Integer.toString(cpt++)).append(". ").append(d.getKind()).append(" in ").append(d.getSource().toUri().getPath()).append(" (at line ").append(Long.toString(d.getLineNumber())).append(")\n");
-             Reader reader = null;
-             try {
-                 reader = d.getSource().openReader(true);
-                 reader.skip(d.getStartPosition());
-                 char[] data = new char[(int) (d.getEndPosition() - d.getStartPosition() + 1)];
-                 reader.read(data);
-                 buffer.append("        ").append(data).append('\n');
-                 Arrays.fill(data, '^');
-                 buffer.append("        ").append(data).append('\n');
-             } catch (IOException e) {
-             } finally {
-                 if (reader != null) {
-                     try {
-                         reader.close();
-                     } catch (IOException e) { }
+             buffer.append(Integer.toString(cpt++)).append(". ").append(d.getKind());
+             if (d.getSource() != null) {
+                 buffer.append(" in ").append(d.getSource().toUri().getPath()).append(" (at line ").append(Long.toString(d.getLineNumber())).append(")\n");
+                 Reader reader = null;
+                 try {
+                     reader = d.getSource().openReader(true);
+                     reader.skip(d.getStartPosition());
+                     char[] data = new char[(int) (d.getEndPosition() - d.getStartPosition() + 1)];
+                     reader.read(data);
+                     buffer.append("        ").append(data).append('\n');
+                     Arrays.fill(data, '^');
+                     buffer.append("        ").append(data).append('\n');
+                 } catch (IOException e) {
+                 } finally {
+                     if (reader != null) {
+                         try {
+                             reader.close();
+                         } catch (IOException e) { }
+                     }
                  }
+             } else {
+                 // this is not a file related error
+                 buffer.append('\n');
              }
              buffer.append(d.getMessage(Locale.getDefault())).append('\n');
          }