<commit_before>package orc.runtime.sites;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

import orc.runtime.Args;
import orc.runtime.Token;
import orc.runtime.sites.java.ObjectProxy;
import orc.runtime.values.Value;

import org.apache.axis.wsdl.toJava.Emitter;
import org.apache.axis.wsdl.toJava.GeneratedFileInfo;
import org.apache.axis.wsdl.toJava.GeneratedFileInfo.Entry;

public class Webservice extends EvalSite {

    // Emitter is the class that does all of the file creation for the WSDL2Java
    // tool.  Using Emitter will allow us to get immediate access to the class names that it
    // generates
    private Emitter emitter;
    private Class locator;
    private Class stub;

    ObjectProxy op;

    // create the java code and get info about that code
    public GeneratedFileInfo createJavaCode(String url) throws Exception {
        emitter = new Emitter();
        emitter.setOutputDir("./webservices/");
        emitter.run(url);
        
        return emitter.getGeneratedFileInfo();
    }

    // compile all of the class files in real-time
    public void compileJavaCode(GeneratedFileInfo info) {
        List<String> fileNames = (ArrayList<String>) info.getFileNames();
        
        for (String file : fileNames) {
            com.sun.tools.javac.Main
                    .compile(new String[] {
                            "-cp",
                            "./webservices:./lib/axis.jar:./lib/jaxrpc.jar",
                            file });
        }
        
        
    }

    @Override
    public void callSite(Args args, Token caller) {

        try {
            // take the passed URL and create java code from it
            GeneratedFileInfo info = createJavaCode(args.stringArg(0));

            // compile that java code
            compileJavaCode(info);
            

            List<Entry> stubs = (ArrayList<Entry>) info.findType("interface");

            
            for(Entry e : stubs){
                Class c = Class.forName(e.className);
                if(c.getName().endsWith("Port") || c.getName().endsWith("PortType")) {
                    stub = Class.forName(e.className);
                    break;
                }
                for (Class iface : c.getInterfaces()) {
                    if (iface.getName().equals("java.rmi.Remote")) {
                        stub = Class.forName(e.className);
                        break;
                    }
                }
            }
            
            if (stub == null) {
                throw new Error("Unable to find stub among port interfaces");
            }           
<commit_msg>Added cross-platform compilation compatibility.<commit_after>package orc.runtime.sites;

import java.io.File;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

import orc.runtime.Args;
import orc.runtime.Token;
import orc.runtime.sites.java.ObjectProxy;
import orc.runtime.values.Value;

import org.apache.axis.wsdl.toJava.Emitter;
import org.apache.axis.wsdl.toJava.GeneratedFileInfo;
import org.apache.axis.wsdl.toJava.GeneratedFileInfo.Entry;

public class Webservice extends EvalSite {
    
    private static final String OUTPUT_DIR = "webservices";
    private static final String CLASSPATH = 
        String.format("webservices%slib%saxis.jar%slib%sjaxrpc.jar", File.pathSeparator, File.separator, File.pathSeparator, File.separator);

    // Emitter is the class that does all of the file creation for the WSDL2Java
    // tool.  Using Emitter will allow us to get immediate access to the class names that it
    // generates
    private Emitter emitter;
    private Class locator;
    private Class stub;

    ObjectProxy op;

    // create the java code and get info about that code
    public GeneratedFileInfo createJavaCode(String url) throws Exception {
        emitter = new Emitter();
        emitter.setOutputDir(OUTPUT_DIR);
        emitter.run(url);
        
        return emitter.getGeneratedFileInfo();
    }

    // compile all of the class files in real-time
    public void compileJavaCode(GeneratedFileInfo info) {
        List<String> fileNames = (ArrayList<String>) info.getFileNames();
        
        for (String file : fileNames) {
            com.sun.tools.javac.Main
                    .compile(new String[] {
                            "-cp",
                            CLASSPATH,
                            file });
        }
        
        
    }

    @Override
    public void callSite(Args args, Token caller) {

        try {
            // take the passed URL and create java code from it
            GeneratedFileInfo info = createJavaCode(args.stringArg(0));
            
            // compile that java code
            compileJavaCode(info);
            

            List<Entry> stubs = (ArrayList<Entry>) info.findType("interface");

            
            for(Entry e : stubs){
                Class c = Class.forName(e.className);
                if(c.getName().endsWith("Port") || c.getName().endsWith("PortType")) {
                    stub = Class.forName(e.className);
                    break;
                }
                for (Class iface : c.getInterfaces()) {
                    if (iface.getName().equals("java.rmi.Remote")) {
                        stub = Class.forName(e.className);
                        break;
                    }
                }
            }
            
            if (stub == null) {
                throw new Error("Unable to find stub among port interfaces");
            }           

{'fraction_non_alphanumeric': 0.09371080451531984, 'fraction_numerical': 0.0007167174341515857, 'mean_word_length': 1.7606330365974283, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2970079', 'n_tokens_mistral': 1499, 'n_tokens_neox': 1431, 'n_words': 381}