Skip to content

Conversation

@Oyami-Srk
Copy link
Contributor

Previously, for the following Cap'n Proto schemas (file ID omitted):

# a.capnp
using Java = import "/capnp/java.capnp";
$Java.package("org.capnproto.examples");
$Java.outerClassname("A");

struct Foo {
    bar @0 : import "b.capnp".Bar;
}

# b.capnp
struct Bar {
    field0 @0 :Text;
}

It would compile with illegal identifiers:

      public final ..Bar.Builder getBar() {
        return _getPointerField(..Bar.factory, 0, null, 0);
      }
      public final void setBar(..Bar.Reader value) {
        _setPointerField(..Bar.factory,0, value);
      }
      public final ..Bar.Builder initBar() {
        return _initPointerField(..Bar.factory,0, 0);
      }

This PR fixes this by adding errors when annotations in imported files are missing, preventing the illegal code from being constructed.

@dwrensha dwrensha merged commit 5150cf7 into capnproto:master Sep 10, 2025
1 check passed
@dwrensha
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants