Step through Java AND Perl code?

Help
MegaJar
2006-08-03
2013-05-20
  • MegaJar
    MegaJar
    2006-08-03

    Hi there. I'm currently developing a project that uses both Java and Perl. It works as follows:
    -The main Java program starts up, and spawns a separate process containing a Perl-based utility.
    -Both processes continue running simultaneously; the Java driver maintains communication with the Perl process via sockets and I/O streams.
    -Once both processes are running, the Java program begins monitoring the LAN for incoming packets. Each time it receives a packet, it does some processing on it, and then sends the processed packet through the sockets to the Perl utility, which does further processing. The Perl utility then sends its results back through the sockets to the Java.

    I just downloaded and installed the EPIC plugin; I successfully created a new Perl project containing the Perl utility's code, and I'm trying to step-through the Perl code in Debug mode. The problem is that the Perl code is set up so that it CAN'T WORK without the sockets in place; which means it MUST be called from the Java program first. And no, I can't rewrite the Perl utility to avoid this problem.

    I already have both the Java code and the Perl code set up as two separate Eclipse projects. What I want to do is to run the Java project, and have it invoke the Perl project; I want to be able to step through the Java code, and CONTINUE stepping through the Perl code when it gets invoked. In other words, I want Eclipse to treat both the Java and the Perl as one program, and move seamlessly from stepping through Java to stepping through Perl.

    Is there a way to accomplish this?

     
    • Jan Ploski
      Jan Ploski
      2006-08-03

      Cross-language debugging from Java into Perl is not supported and would be difficult to implement. You could set up the sockets from a Perl wrapper, though, and stay entirely in the Perl world.

       
    • MegaJar
      MegaJar
      2006-08-03

      Thanks for the reply.

      I don't actually need to debug both the Java and Perl together. I really only need to step-through the Perl code; but since the Perl must be called from the Java, I need to figure out a way to do that.

      What I need is, when the Java calls the Perl, instead of just starting the Perl compiler in a separate process, instead it should invoke the Perl *PROJECT* in Eclipse; I could then set a breakpoint inside the Perl project to begin step-through debugging.

      Is there any way to do that?

       
      • Jae Gangemi
        Jae Gangemi
        2006-08-03

        no - you would probably have to write a java wrapper around part of the eclipse debugging interface and have a way to swap that impl in/out of your java class that invokes the perl process.

        actually - i really don't see any reason why that couldn't work - you'd need to provide an implementation of a launch delegate that then tied into one of the launch targets.

        keep in mind that your impl would somewhat tie you to each epic version. i'm actually working on cleaning up some of the debugger code right now, so already you'd have changes to content w/ once committed.

        if the impl was actually successful, it might be possible to incorporate parts of it into the epic core and provide an extension point to hook into.

        either way, it seems like a lot of work, most of which would fall to you right now.

         
      • Jan Ploski
        Jan Ploski
        2006-08-03

        So you want to "launch a run configuration" within Eclipse's JVM instead of starting your own JVM. I don't think that Eclipse has any direct automation support for controlling it externally. However, it should be fairly easy to achieve your goal using a small custom plug-in. This plug-in would itself execute in the Eclipse JVM and wait for a signal from your standalone Java process, e.g. through a socket or a file. Ask in the Eclipse newsgroups for more information.

         
        • MegaJar
          MegaJar
          2006-08-03

          Thanks for the info, guys.

           
    • MegaJar
      MegaJar
      2006-08-03

      Um.......

      I have absolutely no idea what you just said. Can you explain please? (Sorry, I'm not really well-versed in Eclipse developers' jargon.) *sheepish grin*

       
      • Jae Gangemi
        Jae Gangemi
        2006-08-03

        go read this: http://www.eclipse.org/articles/Article-Debugger/how-to.html

        you would need to integrate launch support into your java application (via an interface so you could swap out the "exec" vs "debug" implementations) that knows how to interface w/ the appropriate epic launch target.

        this is all speculation at this point, but i don't see why it couldn't work.

         
        • MegaJar
          MegaJar
          2006-08-03

          Cool, thanks.

           
    • MegaJar
      MegaJar
      2006-08-04

      Thanks anyway for the help, but I seem to have solved the problem on my own. Basically, the Java code first creates a ServerSocket to listen on a certain port, and then creates a new client process (i.e. the Perl program) on that same port; thus the connection is made. I simply removed the line where it creates the new client process, and instead, when it gets to that point, I manually start up the Perl project myself, in a second Eclipse window. This way, the connection and sockets are made, but I can now step-through the Perl code. Problem solved. :-)

      However...now I have a new problem. I'll post a new thread about it so it doesn't get lost in this one.

       
  • fay
    fay
    2011-11-12

    Hi.

    How to invoke a perl method (function) from java?