{"action":"created","issue":{"url":"https://api.github.com/repos/awslabs/jsii/issues/320","repository_url":"https://api.github.com/repos/awslabs/jsii","labels_url":"https://api.github.com/repos/awslabs/jsii/issues/320/labels{/name}","comments_url":"https://api.github.com/repos/awslabs/jsii/issues/320/comments","events_url":"https://api.github.com/repos/awslabs/jsii/issues/320/events","html_url":"https://github.com/awslabs/jsii/issues/320","id":384218181,"node_id":"MDU6SXNzdWUzODQyMTgxODE=","number":320,"title":"Unable to use Role.import_ in Java CDK","user":{"login":"RomainMuller","id":411689,"node_id":"MDQ6VXNlcjQxMTY4OQ==","avatar_url":"https://avatars2.githubusercontent.com/u/411689?v=4","gravatar_id":"","url":"https://api.github.com/users/RomainMuller","html_url":"https://github.com/RomainMuller","followers_url":"https://api.github.com/users/RomainMuller/followers","following_url":"https://api.github.com/users/RomainMuller/following{/other_user}","gists_url":"https://api.github.com/users/RomainMuller/gists{/gist_id}","starred_url":"https://api.github.com/users/RomainMuller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RomainMuller/subscriptions","organizations_url":"https://api.github.com/users/RomainMuller/orgs","repos_url":"https://api.github.com/users/RomainMuller/repos","events_url":"https://api.github.com/users/RomainMuller/events{/privacy}","received_events_url":"https://api.github.com/users/RomainMuller/received_events","type":"User","site_admin":false},"labels":[{"id":710701460,"node_id":"MDU6TGFiZWw3MTA3MDE0NjA=","url":"https://api.github.com/repos/awslabs/jsii/labels/bug","name":"bug","color":"d73a4a","default":true},{"id":1023664300,"node_id":"MDU6TGFiZWwxMDIzNjY0MzAw","url":"https://api.github.com/repos/awslabs/jsii/labels/java","name":"java","color":"d1a833","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2018-11-26T08:19:02Z","updated_at":"2018-11-26T12:19:02Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"I'm attempting to call `Role.import_(...)` in my Java CDK application, but I'm getting a `ClassCastException` from the CDK library.  Apparently the result that's being returned from the Jsii runtime is a `Construct` which cannot be cast to an `IRole`:\r\n\r\n```\r\nException in thread \"main\" java.lang.ClassCastException: software.amazon.awscdk.Construct cannot be cast to software.amazon.awscdk.services.iam.IRole\r\n\tat software.amazon.awscdk.services.iam.Role.import_(Role.java:24)\r\n\tat MyCallingCode\r\n```\r\n\r\nThe underlying TypeScript ([github](https://github.com/awslabs/aws-cdk/blob/master/packages/%40aws-cdk/aws-iam/lib/role.ts#L84-L88)) declares that it returns `IRole` and explicitly returns an `ImportedRole`, which implements `IRole`, but also *extends* `Construct` ([github](https://github.com/awslabs/aws-cdk/blob/master/packages/%40aws-cdk/aws-iam/lib/role.ts#L227)).  While walking through the Java code in the debugger I see that the result from Jsii's `toString()` shows \"ImportedRole\", but it's type is `Construct`."},"comment":{"url":"https://api.github.com/repos/awslabs/jsii/issues/comments/441619634","html_url":"https://github.com/awslabs/jsii/issues/320#issuecomment-441619634","issue_url":"https://api.github.com/repos/awslabs/jsii/issues/320","id":441619634,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MTYxOTYzNA==","user":{"login":"RomainMuller","id":411689,"node_id":"MDQ6VXNlcjQxMTY4OQ==","avatar_url":"https://avatars2.githubusercontent.com/u/411689?v=4","gravatar_id":"","url":"https://api.github.com/users/RomainMuller","html_url":"https://github.com/RomainMuller","followers_url":"https://api.github.com/users/RomainMuller/followers","following_url":"https://api.github.com/users/RomainMuller/following{/other_user}","gists_url":"https://api.github.com/users/RomainMuller/gists{/gist_id}","starred_url":"https://api.github.com/users/RomainMuller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RomainMuller/subscriptions","organizations_url":"https://api.github.com/users/RomainMuller/orgs","repos_url":"https://api.github.com/users/RomainMuller/repos","events_url":"https://api.github.com/users/RomainMuller/events{/privacy}","received_events_url":"https://api.github.com/users/RomainMuller/received_events","type":"User","site_admin":false},"created_at":"2018-11-26T12:19:02Z","updated_at":"2018-11-26T12:19:02Z","author_association":"CONTRIBUTOR","body":"PR #321 fixes this issue, 🎉"}}
{"actor":{"display_login":"RomainMuller"}}