Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6973245

Different behavior with UAC between JDK 7 and previous release

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P3 P3
    • None
    • 7
    • core-libs
    • x86
    • windows_xp

      Java 7 seems a behaviour with UAC like older Java versions.
      The current Java 6 behaviour seems more correct.
      It throws an IOException if we write to c:\program files.
      Java 7 creates a file in VirtualStore.

      The same problem exists with the system preferences.
      With Java 6 we can read the preferences that a system account can see.
      With Java 7 we receive a mirror in the user scope. This is a regression.

      Here isa test function which behaviour is different in Java 1.6.0_21 and 1.7.0_b100 if UAC is enabled.
       

          private static boolean isWindowsUacEnabled() {
              try {
                  boolean isWindows = System.getProperty( "os.name" ).indexOf( "Windows" ) >= 0;
                  if( !isWindows ) {
                      // Nur für Windows Testen
                      return false;
                  }
                  String osversion = System.getProperty( "os.version" );
                  int spaceposition = osversion.indexOf( " " );
                  if( spaceposition > 0 ) {
                      osversion = osversion.substring( 0, spaceposition );
                  }

                  double version = Double.parseDouble( osversion );
                  boolean isVista = isWindows & version >= 6;

                  if( !isVista ) {
                      // Nur Betriebssysteme ab Vista und höher, solle auch Windows 2008 betreffen
                      return false;
                  }

                  String userHome = System.getProperty( "user.home" );
                  File virtualStore = new File( userHome + "/AppData/Local/VirtualStore/Program Files" );
                  if( !virtualStore.exists() ) {
                      return false;
                  }

                  //"Program Files" wird seit Vista nicht mehr übersetzt, nur der Displaywert wird geändert
                  //Unklar ist nur das Laufwerk

                  String programFilesLocation = null;
                  programFilesLocation = System.getenv( "ProgramFiles" );
                  if (programFilesLocation == null) {
                      return false;
                  }

                  File programFiles = new File( programFilesLocation );
                  if( !programFiles.exists() ) {
                      String javaHome = System.getProperty( "java.home" );
                      int idx = javaHome.indexOf( '\\', 3 );
                      if( idx > 0 ) {
                          programFiles = new File( javaHome.substring( 0, idx ) );
                      }
                  }

                  if( !programFiles.exists() ) {
                      // Program Files wurde nicht gefunden
                      return false;
                  }

                  File tempFile;
                  tempFile = File.createTempFile( "uac", null, programFiles );
                  tempFile.deleteOnExit();

                  File virtualFile = new File( virtualStore, tempFile.getName() );
                  // Die eigentliche Prüfung
                  boolean isUac = virtualFile.exists();
                  tempFile.delete();
                  return isUac;
              } catch( IOException e ) {
                  // ignore weil wir nichts zum Loggen haben
              }
              return false;
          }

            sherman Xueming Shen
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: