POP-Java programmation tutorial

This tutorial provides basic information about the POP-Java programming language and its tools. To have further information (POP-C++ compatibility, Complex object as parameter …) please refer to the POP-Java Documentation.

First parallel class

A POP-Java parallel class is a normal Java class. The main difference is that a @POPClass annotation needs to be added to the class declaration.

 @POPClass
 public class MyFirstParClass {
 } 

A constructor can be added like in a standard class in Java.

 @POPClass
 public class MyFirstParClass {
    public MyFirstParClass(){
    }
 }

Warning: A POP-Java class file must have the extension .pjava

Method invocation semantics

Each method in a parallel class has two invocations semantics. This semantics are divided into two groups:

  • Interface side semantics: These semantics affect how the caller will behave (sync, async)
  • Object side semantics: These are the semantics which affects the call inside the object itself (seq, conc, mutex)

To put specific semantics on a method call, the method must hava a POP-Java semantics annotaton. The following method is asynchronous and sequential.

 @POPAsyncSeq
 public void call1(){
    //Do something
 }

Method which are synchronous can have a return value.

 @POPSyncConc
 public int getValue(){
    return 1;
 }

Using a parallel class

Using a parallel class inside POP-Java code is exactly the same as using a Java class.

 public class MainClass{
    public static void main(String[] args){
       MyFirstParclass mfp = new MyFirstParclass();
       mfp.call1();
       int i = mfp.getValue();
    }
 }

Warning: The class containing the main of a POP-Java application must have the extension .pjava

Object Description

Object Description are used to specify the requirements of an object to the runtime. The Object Description is declared in the object constructor.

 ...
 @POPObjectDescription(url="localhost")
 public MyFirstParclass(){
   //Constrcutor body
 } 

Here is the list of object descriptions available in POP-Java:

  • String url, defines a specific host on which to run the application
  • String jvmParameters, defines the JVM parameters to be used with this object

Compilation and execution

Compiling a POP-Java application

As POP-Java uses a pre-compiler, the parallel classes and standard classes must be compiled with the POP-Java compiler. The POP-Java compiler tool is named popjc.

To compile a POP-Java application, just give the source code to the compiler.

 popjc MyFirstParclass.pjava MainClass.pjava

The POP-Java compiler will produce two class files.

Execute a POP-Java application

To execute a POP-Java application, we need first to create the object map file. The object map file is needed by the POP-C++ runtime to located the executable of the parallel classes. To create this object map file, we use the POP-Java tool popjrun with the option –listlong

popjrun --listlong MyFirstParclass.class > objectmap.xml

Once the object map file is created, we can run the POP-Java application with the same tool.

 popjrun objectmap.xml MainClass
pop-java_programmation_tutorial.txt · Last modified: 2014/02/07 10:56 by wolf
CC Attribution-Share Alike 4.0 International
Powered by PHP Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 Valid HTML5