Title: Unnecessary reflection used for val properties that can be set via constructor · Issue #1190 · UnitTestBot/UTBotJava · GitHub
Open Graph Title: Unnecessary reflection used for val properties that can be set via constructor · Issue #1190 · UnitTestBot/UTBotJava
X Title: Unnecessary reflection used for val properties that can be set via constructor · Issue #1190 · UnitTestBot/UTBotJava
Description: Description If constructor has a val property, codegen doesn't use this constructor but instead instantiates class via reflection although it can normally be done without it. To Reproduce Launch action on the following class: class Custo...
Open Graph Description: Description If constructor has a val property, codegen doesn't use this constructor but instead instantiates class via reflection although it can normally be done without it. To Reproduce Launch ac...
X Description: Description If constructor has a val property, codegen doesn't use this constructor but instead instantiates class via reflection although it can normally be done without it. To Reproduce Launc...
Opengraph URL: https://github.com/UnitTestBot/UTBotJava/issues/1190
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unnecessary reflection used for val properties that can be set via constructor","articleBody":"**Description**\r\n\r\nIf constructor has a val property, codegen doesn't use this constructor but instead instantiates class via reflection although it can normally be done without it.\r\n\r\n**To Reproduce**\r\n\r\nLaunch action on the following class:\r\n\r\n```Kotlin\r\nclass CustomClass(val x: Int) {\r\n fun f(): Int {\r\n return x\r\n }\r\n}\r\n```\r\n\r\n**Expected behavior**\r\n\r\nCorrect tests are generated, reflection is not used at all.\r\n\r\n**Actual behavior**\r\n\r\nGenerated tests contain reflection usage.\r\n\r\n**Visual proofs (screenshots, logs, images)**\r\n\r\nOne of the generated tests:\r\n\r\n```Kotlin\r\n@Test\r\nfun testF1() {\r\n val customClass = (createInstance(\"CustomClass\") as CustomClass)\r\n setField(customClass, \"CustomClass\", \"x\", -255)\r\n \r\n val actual = customClass.f()\r\n \r\n assertEquals(-255, actual)\r\n}\r\n```\r\n","author":{"url":"https://github.com/volivan239","@type":"Person","name":"volivan239"},"datePublished":"2022-10-19T15:30:14.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/1190/UTBotJava/issues/1190"}
| 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:c8887a65-e668-d5bf-f838-c95b53c04eab |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A6FC:296566:8715A4:B2B767:698D788D |
| html-safe-nonce | 95fa60ed55d53a2a61edc391db29970293587a5d4fa666d60e395750fb1b1104 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNkZDOjI5NjU2Njo4NzE1QTQ6QjJCNzY3OjY5OEQ3ODhEIiwidmlzaXRvcl9pZCI6Ijg0MzEwMjEzNzkzNDQ0OTY3ODEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ae2f057cadd066fb797d36d60adaa24d194c52de53e41cbf73d7882763f3910a |
| hovercard-subject-tag | issue:1415186971 |
| 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/1190/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ba3dd106b9b5b839c7a9dff9854971c62385211cb03d936f9a2e1ea03872e0c3/UnitTestBot/UTBotJava/issues/1190 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ba3dd106b9b5b839c7a9dff9854971c62385211cb03d936f9a2e1ea03872e0c3/UnitTestBot/UTBotJava/issues/1190 |
| og:image:alt | Description If constructor has a val property, codegen doesn't use this constructor but instead instantiates class via reflection although it can normally be done without it. To Reproduce Launch ac... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | volivan239 |
| hostname | github.com |
| expected-hostname | github.com |
| None | c0818105fa276287e9369cfdefa0a0fa7953719791ceff9b94d69623c0a4fe8a |
| 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 | 715890fa442134f528fb422ab338c0ad55c7a025 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width