1 /* 2 * Copyright (C) 2009 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package vogar; 18 19 import com.google.common.collect.Iterables; 20 import java.io.File; 21 import java.util.ArrayList; 22 import java.util.Collections; 23 import java.util.List; 24 import java.util.Set; 25 import vogar.commands.VmCommandBuilder; 26 import vogar.tasks.RunActionTask; 27 import vogar.tasks.Task; 28 29 /** 30 * A local Java virtual machine like Harmony or the RI. 31 */ 32 final class JavaVm implements Mode { 33 private final Run run; 34 JavaVm(Run run)35 JavaVm(Run run) { 36 this.run = run; 37 } 38 installTasks()39 @Override public Set<Task> installTasks() { 40 return Collections.emptySet(); 41 } 42 newVmCommandBuilder(Action action, File workingDirectory)43 @Override public VmCommandBuilder newVmCommandBuilder(Action action, File workingDirectory) { 44 List<String> vmCommand = new ArrayList<String>(); 45 Iterables.addAll(vmCommand, run.invokeWith()); 46 vmCommand.add(run.javaPath(run.vmCommand)); 47 VmCommandBuilder vmCommandBuilder = new VmCommandBuilder(run.log) 48 .userDir(workingDirectory) 49 .vmCommand(vmCommand); 50 if (run.debugPort != null) { 51 vmCommandBuilder.vmArgs("-Xrunjdwp:transport=dt_socket,address=" 52 + run.debugPort + ",server=y,suspend=y"); 53 } 54 return vmCommandBuilder; 55 } 56 executeActionTask(Action action, boolean useLargeTimeout)57 @Override public Task executeActionTask(Action action, boolean useLargeTimeout) { 58 return new RunActionTask(run, action, useLargeTimeout); 59 } 60 installActionTasks(Action action, File jar)61 @Override public Set<Task> installActionTasks(Action action, File jar) { 62 return Collections.emptySet(); 63 } 64 getRuntimeClasspath(Action action)65 @Override public Classpath getRuntimeClasspath(Action action) { 66 Classpath result = new Classpath(); 67 result.addAll(run.classpath); 68 result.addAll(run.hostJar(action)); 69 70 /* 71 * For javax.net.ssl tests dependency on Bouncy Castle for 72 * creating a self-signed X509 certificate. Needs to be run 73 * with an openjdk, not a sunjdk, which expects a signed jar 74 * to authenticate security providers. For example: 75 * 76 * --java-home /usr/lib/jvm/java-6-openjdk 77 */ 78 result.addAll(new File("/usr/share/java/bcprov.jar")); 79 80 result.addAll(run.resourceClasspath); 81 return result; 82 } 83 cleanupTasks(Action action)84 @Override public Set<Task> cleanupTasks(Action action) { 85 return Collections.emptySet(); 86 } 87 } 88