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

Allow Launcher to set Factory. Fixes #862. #863

Merged
merged 3 commits into from
Sep 29, 2016
Merged

Conversation

msteinbeck
Copy link
Contributor

No description provided.

@tdurieux tdurieux changed the title Allow Lauchner to set Factory. Fixes #862. Allow Launcher to set Factory. Fixes #862. Sep 28, 2016
@monperrus
Copy link
Collaborator

Immutable objects are better.

Could you do what you want to do with a new constructor "Launcher(Factory f)"

@msteinbeck
Copy link
Contributor Author

Immutable objects are better.

Indeed.

Could you do what you want to do with a new constructor "Launcher(Factory f)"

Yes. Will you add this constructor or should I add another PR?

@monperrus
Copy link
Collaborator

The best thing is to force-push a new commit on this PR/branch.

@msteinbeck
Copy link
Contributor Author

The best thing is to force-push a new commit on this PR/branch.

done.

if (pFactory == null) {
throw new IllegalArgumentException("unable to create launcher with null factory");
}
factory = pFactory;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it voluntary that processArguments is not call in this constructor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You can also call this constructor from the previous one this(createFactory()) in order to reduce code duplication.

Copy link
Contributor Author

@msteinbeck msteinbeck Sep 29, 2016

Choose a reason for hiding this comment

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

I tried but Java (for good reasons) does not allow to call none static methods before this has been called. The actual compiler message is:

cannot reference this before supertype constructor has been called

Copy link
Collaborator

Choose a reason for hiding this comment

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

This constructor will work.

    public Launcher() {
        this(createFactory());
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For me it doesn't. I tried both, OracleJDK (8) and OpenJDK (8).

Copy link
Collaborator

Choose a reason for hiding this comment

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

My bad, createFactory is not static...

This one works but it is hugly.

public Launcher() {
   this(new FactoryImpl(new DefaultCoreFactory(),  new StandardEnvironment()));
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could add another static function to Launcher, or leave it as is (or use your approach). Either one is fine.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It is ok for my to keep it this way.

@tdurieux tdurieux merged commit 9b66538 into INRIA:master Sep 29, 2016
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.

3 participants