Skip to content

Change code examples in Room errors from Java to Kotlin#810

Open
hakonschia wants to merge 1 commit intoandroidx:androidx-mainfrom
hakonschia:update-code-examples-from-java-to-kotlin
Open

Change code examples in Room errors from Java to Kotlin#810
hakonschia wants to merge 1 commit intoandroidx:androidx-mainfrom
hakonschia:update-code-examples-from-java-to-kotlin

Conversation

@hakonschia
Copy link
Copy Markdown

Proposed Changes

When I got this error from Room it confused me as I copied it into my project, but it didn't compile. It took me a minute to realise that the code in the error is for Java and not Kotlin. Considering the state of Kotlin usage on Android (and that Room is also available for KMP) I think it makes more sense for these example snippets to be in Kotlin

Valid Kotlin code

@RenameTable.Entries(
    RenameTable(fromTableName = "...", toTableName = "...")
)
@DeleteTable.Entries(
    DeleteTable(tableName = "...")
)
@RenameColumn.Entries(
    RenameColumn(tableName = "...", fromColumnName = "...", toColumnName = "...")
)
class KotlinMigration : AutoMigrationSpec

Valid Java code

@RenameTable.Entries(
        @RenameTable(fromTableName = "...", toTableName = "...")
)
@DeleteTable.Entries(
        @DeleteTable(tableName = "...")
)
@RenameColumn.Entries(
        @RenameColumn(tableName = "...", fromColumnName = "...", toColumnName = "...")
)
public class JavaMigration implements AutoMigrationSpec {
}

Testing

This PR is just updating documentation

@hakonschia hakonschia requested a review from dlam as a code owner September 14, 2025 07:36
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.

1 participant