

Version 25 (modified by malte.appeltauer, 9 years ago) (diff)



JCop is a context-oriented programming (COP) extension to the Java programming language. It combines COP features - introduced by its predecessor ContextJ - with new constructs for declarative and event-based layer composition and a first-class event-based context representation.

Modularization. Behavioral variations are modularized by layers that can either be defined within classes (layer-in-class) or in dedicated top-level modules (class-in-layer). Layers contain partial method definitions that extend or replace a plain method while their layers are active.

Dynamic Composition. JCop provides control-flow specific layer composition as known from other COP languages. In addition, it offers declarative composition statements that are specified within context modules and thus combines COP with concepts of aspect-oriented programming.

For more information, please see our publications related to the JCop and ContextJ project or contact the main contributors

Downloads & Installation

Required Files

An archive containing the latest version of JCop and all necessary ﬁles is available in our repository. In addition, a JVM 1.5 or higher must be installed on the system.

The archive contains the following ﬁles that are required to run the compiler via command line. Besides the platform independent JAR archives the JCop distribution contains command scripts for Windows and Unix systems.

  • jcop.jar, Executable archive that contains the JCop compiler.
  • aspectjtools.jar, aspectjrt.jar, AspectJ libraries that are required by jcop.jar.
  • aspectjweaver.jar, AspectJlibrary that is required for VM instrumentation at runtime.
  • agg_V165_classes.jar, AGG library required to generate an AGG graph instead of bytecode.
  • jcopc and jcop scripts for compilation and launching of JCop applications

Environment Variables

The compiler requires a JCOP_HOME environment variable pointing to the directory in which the above archives and scripts are located. For convenience, the folder should also be added to the path variable to ease the access to the command scripts.

Command Line Tools

In the following we describe the usage of the JCop language compiler that is able to compile programs of the JCop and Java programming language. The compiler implements the language as deﬁned in the JCop language speciﬁcation ver- sion 1.0. The language deﬁnition has continuously been revised to precisely specify the language including various corner cases and combinations of features. The compiler is an extension to the JastAddJ Java compiler that is implemented based on the JastAdd compiler framework.



jcopc [Options] [file]


The jcopc command compiles JCop and Java source, producing .class ﬁles compliant with any Java VM (1.1 or later). The argument after the options speciﬁes the source ﬁle to compile. Source ﬁles are speciﬁed by their full qualiﬁed name (package name + type name), separated by a dot (".") (rather than a folder delimiter as for javac).


-classpath <path>

Specify where to ﬁnd user class ﬁles and annotation processors.

-sourcepath <path>

Specify where to ﬁnd input source ﬁles. Only required if the sources aren’t located in the working directory.

jcopc  -sourcepath  src  myPckg.MyMainClass 

-d <directory>

Specify where to place generated class ﬁles.

jcopc  -d  bin  -sourcepath  src  myPckg.MyMainClass 

-sourcedump <path>

Dumps Java source ﬁles of the compiled classes into the speciﬁed folder.

jcopc  -sourcedump  dump  myPckg.MyMainClass 

-agg <path>

Generates a ﬁle containing an AGG graph representation of the program’s AST.

jcopc  -agg  output/agg  myPckg.MyMainClass 


Output JCop speciﬁc messages about what the compiler is doing.

jcopc  -ctl  myPckg.MyMainClass 
>  copying
>  to  src\jcop\lang
>  ..done
>  compiling:...src\de\uni_potsdam\hpi\swa\Widget.jcop  ..done
>  compiling:jcop\lang\  ..done
>  ..done
>  compile  and  weave  auxilliary  aspect    bin\jcop\lang\JCopAspect.aj
>  ..done
>  compiled  in  3723  millis


Loggs layer activation and composition information at runtime.

jcopc  -rtl  myPckg.MyMainClass
>  INFO:  accessing  base  method  of  getBMI
>  INFO:  accessing  method  getBMI  of  layer  Visualization


Output messages about what the compiler is doing


Print a synopsis of standard options


Output messages about aspect weaving


Print version information.

-xml-outline-path <path>

Generate an outline in XML format (useful for development environments)


Generate an outline in XML format (useful for development environments)

File Names

jcopc accepts source ﬁles with either the .java extension or the .jcop extension.



jcop [Options] class [ argument ]


The jcop command launches a JCop or Java application. It does this by starting a Java runtime environment (instrumented with the AspectJ weaver), loading a specified class, and invoking that class's main method. The method declaration must look like a plain Java main method:

public static void main(String args[]) {...}

The method must be declared public and static, it must not return any value, and it must accept a String array as a parameter. By default, the first non-option argument is the name of the class to be invoked. A fully-qualified class name should be used.

The argument after the options specifies the class file to compile and by its full qualified name (package name + type name), separated by a dot (".").


As options all standard Java options are allowed.

File Names

jcop accepts Java bytecode files with the class extension.