Skip to content

className/Class<?> pairings not necessarily same as className/sourceCode #17

Open

Description

@kaya3

Calling addSource("A", "class B {}"); addSource("B", "class A {}"); compileAll(); returns a Map of "A" to the class A and "B" to the class B. This is unexpected, and means that compileAll().get(className) won't necessarily return the class compiled from the source code for className.

This could cause problems if, for example, client code ensures that the source code for "A" declares a class with some property, and then expects compileAll().get("A") to return a class with that property.

A suggested fix is for the compileAll() method to check that the source code associated with each class name does declare a class of that name, and throw a CompilationException otherwise. This mirrors the behaviour of javac which requires a file named A.java to declare a class named A.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions