Skip to content

asn1bean-compiler generates code that doesn't compile when a field is called 'length' #46

Description

@morten-holm

Using the asn1bean-compiler on this asn file generates a .java file that does not compile:

TEST
DEFINITIONS IMPLICIT TAGS       ::=

BEGIN

ContentInfo  ::= SEQUENCE
{
     extensionType		[0]	INTEGER,
     length			[1]	INTEGER
}

END

It generates this (lines 118-128):

		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
			length = new BerInteger();
			vByteCount += length.decode(is, false);
			if (lengthVal >= 0 && vByteCount == lengthVal) {
				return tlByteCount + vByteCount;
			}
			vByteCount += berTag.decode(is);
		}
		else {
			throw new IOException("Tag does not match mandatory sequence component.");
		}

And the problem is obviously that a BerInteger is assigned to the local length variable of type BerLength. A trivial fix could be adding this.-prefix to class variable assignments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions