Unable to perform rotation operation in android appium 8.5.1

I have tries this below code:
DeviceRotation r = new DeviceRotation(0,0,90);
((SupportsRotation)driver).rotate( r);

its throwing error : class io.appium.java_client.AppiumDriver cannot be cast to class io.appium.java_client.remote.SupportsRotation (io.appium.java_client.AppiumDriver and io.appium.java_client.remote.SupportsRotation are in unnamed module of loader ‘app’)