void () { setupPaths(); checkClassFromLib("test.A", "1"); final ModifiableRootModel rootModel = ModuleRootManager.getInstance(myModule).getModifiableModel(); final OrderEntry[] order = rootModel.getOrderEntries(); final int length = order.length; OrderEntry lib2 = order[length - 1]; OrderEntry lib1 = order[length - 2]; assertTrue(lib1 instanceof LibraryOrderEntry); assertEquals("lib1", ((LibraryOrderEntry) lib1).getLibraryName()); assertTrue(lib2 instanceof LibraryOrderEntry); assertEquals("lib2", ((LibraryOrderEntry) lib2).getLibraryName()); order[length - 1] = lib1; order[length - 2] = lib2; rootModel.rearrangeOrderEntries(order); ApplicationManager.getApplication().runWriteAction(() -> rootModel.commit() ); checkClassFromLib("test.A", "2"); }