Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
morten-holm opened this issue Sep 1, 2022 · 0 comments

Comments

@morten-holm
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant