Skip to content

Java: Fix interface expansions #153

Open
@kindlich

Description

@kindlich

ZenCode offers the functionality to make an existing class implement new interfaces.
Example code would be:

public class Point2D {
    public var x as usize;
    public var x as usize;

    public this(x: usize, y: usize) { this.x = x; this.y = y; }
}

public interface CommandStringDisplayable {
    public get commandString as string;
}

public expand MyClass {
    public implements CommandStringDisplayable {
        public get commandString => "<point:" + x + ":" + y + ">";
    }
}

Currently, while this code (probably) parses and passes validation, it breaks at Java Compilation.
Reason is that this functionality was never implemented for the Java side.
We need to implement this for the Java Bytecode side or decide how to deal with this otherwise

Acceptance criteria:

  • Have decided on a plan on how to implement this OR Have decided that this should not be possible on ZC Java
  • How to integrate with Java-Code
    • what should new MyClass() instanceof CommandStringDisplayable return?
    • How to add interfaces to existing Java Classes?
    • Can interfaces be added to final classes?
  • Edge Cases:
    • Interface already implemented either by original class or by another expansion => Error
    • Conflicting method definition in 2 interfaces => Decide: Error or okay?

Metadata

Metadata

Assignees

No one assigned

    Labels

    JavaIntegrationAll issues that relate to integrating ZenCode with existing Java CodebugSomething isn't workingbytecodeAll issues that relate to the generation of Java Bytecode

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions