ASN1C icon ASN.1 to Java

ASN.1 to Java diagram

The ASN1C ASN.1 compiler can generate Java source code for encoding and decoding ASN.1 messages. The following ASN.1 encoding rules are supported:

  • PER - aligned (APER) and unaligned (UPER)
  • OER (including canonical COER)
  • XER and OSys XML

Generated Java encoders/decoders and run-time are a 100% pure Java solution for encoding an decoding ASN.1-based messages.

The generated Java code consists of a series of Java source files - one for each production (type) defined within an ASN.1 specification. Each of these Java files contains (at a minimum) the following items:

  • A public member data variable (or variables) to hold data of the generated type.
  • A constructor (or constructors) to initialize the variable.
  • An encode method.
  • A decode method.
  • A print method to print the contents of the object to a given output stream.

There is also a run-time library for Java. This consists of a series of classes for encoding and decoding the primitive ASN.1 types. For example, the Asn1Integer class will encode or decode a variable of the ASN.1 INTEGER type. The compiler will extend these base classes to form higher level types derived directly from the base types, or assemble a series of these lower level objects to form constructed types (SEQUENCE, for example).


  • Intuitive mapping between ASN.1 type and Java classes.
  • In-memory and stream-based encoding and decoding.
  • Support for Java Micro Edition Connected Limited Device Configuration (CLDC)
  • Supports generation of utility functions to print, compare, and copy data in generated structures.
  • Supports generation of random test data and reader and writer programs
  • Supports generation of ant build.xml files to build generated code as well as support for Maven and Gradle build frameworks.
  • Comprehensive ASN.1 feature coverage including support for table constraints, content constraints, extension element groups, all ASN.1 types, and ASN.1 value notation.
  • SAX-like event handler interface allows for user-defined callbacks
  • NAS extensions make it possible to generate Java code to support 3GPP layer 3 messages using a specially constructed ASN.1 specification.