Skip to content

Need help to execute compiled code #292

@dennis508

Description

@dennis508

Need an example of compilation and separate execution.

public static void main(String[] args) {
        
    // exiftool -ver
    String newargs[] = new String[]{
        "/C/F/Projects/PerlOnJava/Image-ExifTool-13.50/exiftool",
        "-ver"};
    
    CompilerOptions parsedArgs = ArgumentParser.parseArguments(newargs);

    if (parsedArgs.code == null) {
        System.err.println("No code provided. Use -e <code> or specify a filename.");
        System.exit(1);
    }

    try {
        Object executable = PerlLanguageProvider.compilePerlCode(parsedArgs);
        
        // How to execute? What is that returned object?

The compilePerlCode comments say "The compiled code instance (can be used with RuntimeCode.apply via MethodHandle)" but it is not clear how to do this. There are references to executing compiled code in perlonjava-web.md and java-integration.md but these may not be up to date.

This is a good time to ask if what I want to do will ever work. What I want to do is compile ExifTool once and then execute it many times with different arguments. The speed and size characteristics must be comparable to standard Perl.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions