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

Looking up methods is awkward #91

Closed
dmlloyd opened this issue Nov 3, 2020 · 1 comment
Closed

Looking up methods is awkward #91

dmlloyd opened this issue Nov 3, 2020 · 1 comment
Labels
area: compiler An issue which relates the compiler area kind: enhancement ✨ A new feature or use case

Comments

@dmlloyd
Copy link
Collaborator

dmlloyd commented Nov 3, 2020

It would be nice to improve method lookup. Right now, this is what is necessary to find the standard main method:

        DefinedTypeDefinition stringClass = bcc.findDefinedType("java/lang/String");
        if (stringClass == null) {
            context.error("String class not found (missing JDK?)");
            return delegate;
        }
        TypeSystem ts = context.getTypeSystem();
        LiteralFactory lf = context.getLiteralFactory();
        ReferenceType stringArray = ts.getReferenceType(lf.literalOfArrayType(ts.getReferenceType(stringClass.validate().getTypeId())));
        int idx = userMainClass.validate().resolve().findMethodIndex("main", MethodDescriptor.of(ParameterizedExecutableDescriptor.of(stringArray), ts.getVoidType()));
        if (idx == -1) {
            context.error("No main method found on main class %s", mainClassName);
            return delegate; // bail out
        }
        final MethodElement userMain = userMainClass.validate().getMethod(idx);

(edited because it's actually even worse)

@dmlloyd dmlloyd added area: compiler An issue which relates the compiler area kind: enhancement ✨ A new feature or use case labels Nov 3, 2020
@dmlloyd
Copy link
Collaborator Author

dmlloyd commented Oct 7, 2021

This is largely improved now.

@dmlloyd dmlloyd closed this as completed Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: compiler An issue which relates the compiler area kind: enhancement ✨ A new feature or use case
Projects
None yet
Development

No branches or pull requests

1 participant