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

Use Classgraph to Import Unknown Packages Not Yet Loaded #3395

Merged
merged 4 commits into from
Feb 3, 2023

Conversation

nbauernfeind
Copy link
Member

Fixes #1129.

@nbauernfeind nbauernfeind added bug Something isn't working query engine NoDocumentationNeeded groovy NoReleaseNotesNeeded No release notes are needed. labels Feb 1, 2023
@nbauernfeind nbauernfeind added this to the Jan 2023 milestone Feb 1, 2023
@nbauernfeind nbauernfeind self-assigned this Feb 1, 2023
@@ -52,6 +52,7 @@ dependencies {
// TODO(deephaven-core#3204): t-digest 3.3 appears to have higher errors than 3.2
implementation 'com.tdunning:t-digest:3.2'
implementation 'com.squareup:javapoet:1.13.0'
implementation 'io.github.classgraph:classgraph:4.8.103'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like classgraph. We need to decide if this additional dependency is worth it. It doesn't have any external dependencies itself, which is nice.

I'd bump to the latest version.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've bumped. I'd be interested in any other approach you have in mind. The reported bug is an annoying thing for the user to need to handle.

Maybe we should make groovy-support an extension?

Copy link
Member

@devinrsmith devinrsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one more point.

devinrsmith
devinrsmith previously approved these changes Feb 2, 2023
Copy link
Member

@devinrsmith devinrsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's check w/ @rcaudy too

@nbauernfeind
Copy link
Member Author

I can verify that class graph does not initialize any classes until they are actually loaded:

package io.deephaven.server;

public class TestStatic {
    static {
        System.out.println("Initializing TestStatic");
    }
}

I ran three commands one at a time, in this order:

import io.deephaven.server.barrage.*
import io.deephaven.server.*
import io.deephaven.server.TestStatic

Only the last of which printed my static initializer:

Initializing TestStatic

@nbauernfeind
Copy link
Member Author

Including Ryan's request to avoid initializing the class, this TestStatic class is not initialized until after it is actually used.

Results in no output:

import io.deephaven.server.TestStatic

Can finish loading the class like so:

println(TestStatic.class.toString())

Yields:

- Initializing TestStatic
- class io.deephaven.server.TestStatic

@nbauernfeind nbauernfeind merged commit 5fe14fa into deephaven:main Feb 3, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Feb 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working groovy NoDocumentationNeeded NoReleaseNotesNeeded No release notes are needed. query engine
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Importing groovy.time.* results in an error
3 participants