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

Fix searching of modifiers field for JDK 8-17 #408

Merged
merged 1 commit into from
Jul 7, 2022

Conversation

sergeypospelov
Copy link
Member

@sergeypospelov sergeypospelov commented Jul 5, 2022

Description

Changed the way of searching modifiers field in ReflectionUtil.kt. The suggested change works for JDK 8-17, but doesn't work for JDK 18.

Fixes #374

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Manual Scenario

Repeated To Reproduce section from the #374:

Steps to reproduce the behavior:

  1. Define JDK-13 as primary (Path, JAVA_HOME)
  2. Download one of the latest CLI from master
  3. For simplicity in the folder where utbot-cli*.jar is located :
    Create ExampleString.java using var (feature introduced in Java 9)
public class ExampleString {

    public void stringNewMethod() {
        var text = "Hello!\n This is String defined with var";

        text = text.toLowerCase();
        System.out.println(text);

        text = text.toUpperCase();
        System.out.println(text);
    }
}
  1. Compile your files with JDK-13

javac -version

javac ExampleString.class

  1. Run utbot-cli to generate tests for it, like that:

java -jar utbot-cli-2022.7.jar generate --source ExampleString.java --classpath "D:\Current\Java" -o ExampleStringTest.java ExampleString

Tests are generated.

Checklist (remove irrelevant options):

  • The change followed the style guidelines of the UTBot project
  • Self-review of the code is passed
  • The change contains enough commentaries, particularly in hard-to-understand areas
  • New documentation is provided or existed one is altered
  • No new warnings
  • Tests that prove my change is effective
  • All tests pass locally with my changes

Sorry, something went wrong.

@sergeypospelov sergeypospelov requested a review from dtim July 5, 2022 07:37
Copy link
Collaborator

@dtim dtim left a comment

Choose a reason for hiding this comment

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

LGTM

@sergeypospelov sergeypospelov self-assigned this Jul 7, 2022
@sergeypospelov sergeypospelov merged commit a92e289 into main Jul 7, 2022
@sergeypospelov sergeypospelov deleted the fix-modifiers-field-search-for-jdk-17 branch July 7, 2022 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

var with JDK 13 - CLI throws "NoSuchFieldException: modifiers"
2 participants