< prev index next >

src/com/sun/javatest/agent/Agent.java

Print this page
rev 152 : 7902253: Remove unnecessary array creation for varargs parameters
7902245: Correct Agent.productVersion
Reviewed-by: jjg


 578     static final short protocolVersion = 105;
 579 
 580     /**
 581      * The default port to which active agents will try and connect on a nominated host.
 582      */
 583     public static final int defaultActivePort = 1907;
 584 
 585     /**
 586      * The default port on which passive ports will listen for incoming connections.
 587      */
 588     public static final int defaultPassivePort = 1908;
 589 
 590     static final byte CLASS = (byte)'C';
 591     static final byte DATA = (byte)'D';
 592     static final byte LOG = (byte)'L';
 593     static final byte LOG_FLUSH = (byte)'l';
 594     static final byte REF = (byte)'R';
 595     static final byte REF_FLUSH = (byte)'r';
 596     static final byte STATUS = (byte)'S';
 597 
 598     static final String productName = "JT Harness Agent";
 599     static final String productVersion = "JTA_5.0";
 600     static final String productCopyright = "Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.";
 601 
 602 
 603     /**
 604      * Tasks handle the individual requests received by Agent.
 605      * They read the request from the connection, execute the request, which means
 606      * running the test class on behalf of the client, and any output from the
 607      * test class is written back to the client via the connection.
 608      */
 609     class Task {
 610         Task(Connection c) {
 611             if (c == null)
 612                 throw new NullPointerException();
 613             connection = c;
 614         }
 615 
 616         public void handleRequest() throws ConnectionFactory.Fault {
 617 
 618             try {
 619                 notifier.openedConnection(connection);
 620 


 928                 executeThread.setPriority(Thread.MIN_PRIORITY);
 929                 executeThread.interrupt();
 930                 if (alarmTimer != null){
 931                     alarmTimer.finished();
 932                 }
 933 
 934                 return result;
 935             }
 936 
 937         }
 938 
 939         private Status executeMain(Class<?> c, String[] args,
 940                 PrintWriter testLog, PrintWriter testRef)
 941                 throws IOException, ClassNotFoundException, IllegalAccessException {
 942             notifier.execMain(connection, tag, c.getName(), args);
 943 
 944             PrintStream out = Deprecated.createPrintStream(new WriterStream(testRef));
 945             PrintStream err = Deprecated.createPrintStream(new WriterStream(testLog));
 946             try {
 947                 setSystemStreams(this, out, err);
 948                 Method main = c.getDeclaredMethod("main", new Class<?>[] {String[].class});
 949                 main.invoke(null, new Object[] {args});
 950                 return Status.passed("OK");
 951             } catch (NoSuchMethodException e) {
 952                 return Status.error("Can't find `public static void main(String[] args)' for `" + c.getName() + "'");
 953             } catch (InvocationTargetException e) {
 954                 Throwable t = e.getTargetException();
 955                 t.printStackTrace(err);
 956                 return Status.failed(t.toString());
 957             } catch (InterruptedException e) {
 958                 return Status.failed("interrupted while waiting for access to system streams");
 959             } finally {
 960                 resetSystemStreams(this);
 961                 out.flush();
 962                 err.flush();
 963             }
 964         }
 965 
 966         /**
 967          * Close the task, abandoning any request in progress.
 968          */




 578     static final short protocolVersion = 105;
 579 
 580     /**
 581      * The default port to which active agents will try and connect on a nominated host.
 582      */
 583     public static final int defaultActivePort = 1907;
 584 
 585     /**
 586      * The default port on which passive ports will listen for incoming connections.
 587      */
 588     public static final int defaultPassivePort = 1908;
 589 
 590     static final byte CLASS = (byte)'C';
 591     static final byte DATA = (byte)'D';
 592     static final byte LOG = (byte)'L';
 593     static final byte LOG_FLUSH = (byte)'l';
 594     static final byte REF = (byte)'R';
 595     static final byte REF_FLUSH = (byte)'r';
 596     static final byte STATUS = (byte)'S';
 597 
 598     static final String PRODUCT_NAME = "JT Harness Agent";
 599     static final String PRODUCT_VERSION = "JTA_6.0";
 600     static final String PRODUCT_COPYRIGHT = "Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.";
 601 
 602 
 603     /**
 604      * Tasks handle the individual requests received by Agent.
 605      * They read the request from the connection, execute the request, which means
 606      * running the test class on behalf of the client, and any output from the
 607      * test class is written back to the client via the connection.
 608      */
 609     class Task {
 610         Task(Connection c) {
 611             if (c == null)
 612                 throw new NullPointerException();
 613             connection = c;
 614         }
 615 
 616         public void handleRequest() throws ConnectionFactory.Fault {
 617 
 618             try {
 619                 notifier.openedConnection(connection);
 620 


 928                 executeThread.setPriority(Thread.MIN_PRIORITY);
 929                 executeThread.interrupt();
 930                 if (alarmTimer != null){
 931                     alarmTimer.finished();
 932                 }
 933 
 934                 return result;
 935             }
 936 
 937         }
 938 
 939         private Status executeMain(Class<?> c, String[] args,
 940                 PrintWriter testLog, PrintWriter testRef)
 941                 throws IOException, ClassNotFoundException, IllegalAccessException {
 942             notifier.execMain(connection, tag, c.getName(), args);
 943 
 944             PrintStream out = Deprecated.createPrintStream(new WriterStream(testRef));
 945             PrintStream err = Deprecated.createPrintStream(new WriterStream(testLog));
 946             try {
 947                 setSystemStreams(this, out, err);
 948                 Method main = c.getDeclaredMethod("main", String[].class);
 949                 main.invoke(null, new Object[] {args});
 950                 return Status.passed("OK");
 951             } catch (NoSuchMethodException e) {
 952                 return Status.error("Can't find `public static void main(String[] args)' for `" + c.getName() + "'");
 953             } catch (InvocationTargetException e) {
 954                 Throwable t = e.getTargetException();
 955                 t.printStackTrace(err);
 956                 return Status.failed(t.toString());
 957             } catch (InterruptedException e) {
 958                 return Status.failed("interrupted while waiting for access to system streams");
 959             } finally {
 960                 resetSystemStreams(this);
 961                 out.flush();
 962                 err.flush();
 963             }
 964         }
 965 
 966         /**
 967          * Close the task, abandoning any request in progress.
 968          */


< prev index next >