Title: Incorrect reflection call leads to compilation errors · Issue #1024 · UnitTestBot/UTBotJava · GitHub
Open Graph Title: Incorrect reflection call leads to compilation errors · Issue #1024 · UnitTestBot/UTBotJava
X Title: Incorrect reflection call leads to compilation errors · Issue #1024 · UnitTestBot/UTBotJava
Description: Description Try to generate tests for the following class, set timeout at least to 60s. import org.antlr.runtime.tree.TreeVisitor; import org.antlr.runtime.tree.TreeVisitorAction; import org.antlr.v4.parse.GrammarASTAdaptor; import org.a...
Open Graph Description: Description Try to generate tests for the following class, set timeout at least to 60s. import org.antlr.runtime.tree.TreeVisitor; import org.antlr.runtime.tree.TreeVisitorAction; import org.antlr....
X Description: Description Try to generate tests for the following class, set timeout at least to 60s. import org.antlr.runtime.tree.TreeVisitor; import org.antlr.runtime.tree.TreeVisitorAction; import org.antlr....
Opengraph URL: https://github.com/UnitTestBot/UTBotJava/issues/1024
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incorrect reflection call leads to compilation errors","articleBody":"**Description**\r\n\r\nTry to generate tests for the following class, set timeout at least to 60s.\r\n\r\n```java\r\nimport org.antlr.runtime.tree.TreeVisitor;\r\nimport org.antlr.runtime.tree.TreeVisitorAction;\r\nimport org.antlr.v4.parse.GrammarASTAdaptor;\r\nimport org.antlr.v4.tool.ast.GrammarAST;\r\n\r\npublic class Grammarin {\r\n public void setGrammarPtr(final org.antlr.v4.tool.Grammar g, GrammarAST tree) {\r\n if (tree != null) {\r\n TreeVisitor v = new TreeVisitor(new GrammarASTAdaptor());\r\n v.visit(tree, new TreeVisitorAction() {\r\n public Object pre(Object t) {\r\n ((GrammarAST) t).g = g;\r\n return t;\r\n }\r\n\r\n public Object post(Object t) {\r\n return t;\r\n }\r\n });\r\n }\r\n }\r\n}\r\n```\r\n\r\nThe following code i generated:\r\n\r\n```java\r\n @Test\r\n @DisplayName(\"setGrammarPtr: -\u003e tree != null : True\")\r\n public void testSetGrammarPtr_TreeNotEqualsNull_2() throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException {\r\n Grammarin grammarin = new Grammarin();\r\n GrammarRootAST tree = new GrammarRootAST(null);\r\n tree.token = null;\r\n Class baseTreeClazz = Class.forName(\"org.antlr.runtime.tree.BaseTree\");\r\n Field childrenField = baseTreeClazz.getDeclaredField(\"children\");\r\n childrenField.setAccessible(true);\r\n childrenField.get(tree) = new ArrayList();\r\n\r\n grammarin.setGrammarPtr(null, tree);\r\n }\r\n```\r\n\r\nLine with getter leads to the compilation error\r\n```\r\nchildrenField.get(tree) = new ArrayList(); - variable expected\r\n```\r\n","author":{"url":"https://github.com/EgorkaKulikov","@type":"Person","name":"EgorkaKulikov"},"datePublished":"2022-09-28T08:48:32.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/1024/UTBotJava/issues/1024"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e8e644e7-237f-1750-85c1-3090875e5459 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A36C:126D8E:14CEFD:1C5470:698ED87D |
| html-safe-nonce | 4ea63560e2a3528efacc24cc1910eae21ff9fb2ad5e5b151d1b6fff467f501ab |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMzZDOjEyNkQ4RToxNENFRkQ6MUM1NDcwOjY5OEVEODdEIiwidmlzaXRvcl9pZCI6IjcwNTcyMTQ5NzIzMzQzNjQ3OTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 59a9e92c4d5c346c46b081bd078bdf499fa48bfa4c55aca5083e92857cecf3f2 |
| hovercard-subject-tag | issue:1388975048 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/UnitTestBot/UTBotJava/1024/issue_layout |
| twitter:image | https://opengraph.githubassets.com/01137da37dca33142683b880ca0e4ff3a522e19a05f2067790339c937b57e642/UnitTestBot/UTBotJava/issues/1024 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/01137da37dca33142683b880ca0e4ff3a522e19a05f2067790339c937b57e642/UnitTestBot/UTBotJava/issues/1024 |
| og:image:alt | Description Try to generate tests for the following class, set timeout at least to 60s. import org.antlr.runtime.tree.TreeVisitor; import org.antlr.runtime.tree.TreeVisitorAction; import org.antlr.... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | EgorkaKulikov |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb2828a801ee6b7be618f3ac76fbf55def35bbc30f053a9c41bf90210b8b72ba |
| turbo-cache-control | no-preview |
| go-import | github.com/UnitTestBot/UTBotJava git https://github.com/UnitTestBot/UTBotJava.git |
| octolytics-dimension-user_id | 87413538 |
| octolytics-dimension-user_login | UnitTestBot |
| octolytics-dimension-repository_id | 480810501 |
| octolytics-dimension-repository_nwo | UnitTestBot/UTBotJava |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 480810501 |
| octolytics-dimension-repository_network_root_nwo | UnitTestBot/UTBotJava |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e6b91a7e6e46287d26887e3fb7a4161657bab8f7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width