This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Product Version: NetBeans IDE Dev (Build 201110310600) Java: 1.7.0; Java HotSpot(TM) Client VM 21.0-b17 System: Windows 7 version 6.1 running on x86; Cp1252; en_US (nb) User directory: C:\Users\g.tzabari\.netbeans\dev Cache directory: C:\Users\g.tzabari\.netbeans\dev\var\cache 1. Given: public static class NativeLibraries { private static final Field loadedLibraryNames; private static final Field systemNativeLibraries; private static final Field nativeLibraries; private static final Field nativeLibraryFromClass; private static final Field nativeLibraryName; static { Field temp; try { temp = ClassLoader.class.getDeclaredField("loadedLibraryNames"); if (temp != null) temp.setAccessible(true); } catch (ReflectiveOperationException e) { e.printStackTrace(); temp = null; } loadedLibraryNames = temp; try { temp = ClassLoader.class.getDeclaredField("systemNativeLibraries"); if (temp != null) temp.setAccessible(true); } catch (ReflectiveOperationException e) { e.printStackTrace(); temp = null; } systemNativeLibraries = temp; try { temp = ClassLoader.class.getDeclaredField("nativeLibraries"); if (temp != null) temp.setAccessible(true); } catch (ReflectiveOperationException e) { e.printStackTrace(); temp = null; } nativeLibraries = temp; Class<?> nativeLibrary = null; for (Class<?> nested : ClassLoader.class.getDeclaredClasses()) { if (nested.getSimpleName().equals("NativeLibrary")) { nativeLibrary = nested; break; } } try { temp = nativeLibrary.getDeclaredField("fromClass"); if (temp != null) temp.setAccessible(true); } catch (ReflectiveOperationException e) { e.printStackTrace(); temp = null; } nativeLibraryFromClass = temp; try { temp = nativeLibrary.getDeclaredField("name"); if (temp != null) temp.setAccessible(true); } catch (ReflectiveOperationException e) { e.printStackTrace(); temp = null; } nativeLibraryName = temp; } public static String[] getLoadedLibraries() { try { @SuppressWarnings("UseOfObsoleteCollectionType") final Vector<String> libraries = (Vector<String>) loadedLibraryNames.get(null); return libraries.toArray(new String[0]); } catch (ReflectiveOperationException e) { e.printStackTrace(); return null; } } /** * Returns the native libraries loaded by the system class loader. * <p/> * @return a Map from the names of native libraries to the classes that loaded them */ public static Map<String, Class<?>> getSystemNativeLibraries() { try { @SuppressWarnings("UseOfObsoleteCollectionType") Map<String, Class<?>> result = new HashMap<>(); final Vector<Object> libraries = (Vector<Object>) systemNativeLibraries.get(null); for (Object nativeLibrary : libraries) { String libraryName = (String) nativeLibraryName.get(nativeLibrary); Class<?> fromClass = (Class<?>) nativeLibraryFromClass.get(nativeLibrary); result.put(libraryName, fromClass); } return result; } catch (ReflectiveOperationException e) { e.printStackTrace(); return null; } } /** * Returns a Map from the names of native libraries to the classes that loaded them. * <p/> * @param loader the ClassLoader that loaded the libraries * @return an empty Map if no native libraries were loaded */ public static Map<String, Class<?>> getNativeLibraries(final ClassLoader loader) { try { @SuppressWarnings("UseOfObsoleteCollectionType") Map<String, Class<?>> result = new HashMap<>(); final Vector<Object> libraries = (Vector<Object>) nativeLibraries.get(loader); for (Object nativeLibrary : libraries) { String libraryName = (String) nativeLibraryName.get(nativeLibrary); Class<?> fromClass = (Class<?>) nativeLibraryFromClass.get(nativeLibrary); result.put(libraryName, fromClass); } return result; } catch (ReflectiveOperationException e) { e.printStackTrace(); return null; } } public static List<ClassLoader> getClassLoaders(ClassLoader loader) { List<ClassLoader> result = new ArrayList<>(); ClassLoader parent = loader.getParent(); result.add(loader); while (parent != null) { result.add(parent); parent = parent.getParent(); } return result; } /** * Returns a Map from the names of native libraries to the classes that loaded them. * <p/> * @param loader the ClassLoader that loaded the libraries * @return an empty Map if no native libraries were loaded */ public static Map<String, Class<?>> getNativeLibrariesRecursive(final ClassLoader loader) { @SuppressWarnings("UseOfObsoleteCollectionType") Map<String, Class<?>> result = new HashMap<>(); ClassLoader parent = loader.getParent(); while (parent != null) { result.putAll(getNativeLibrariesRecursive(parent)); parent = parent.getParent(); } result.putAll(getNativeLibraries(loader)); return result; } } 2. Refactor -> Move Inner to Outer Level -> OK 3. Resulting class is mangled: /* * To change this template, choose Tools | Templates * and open the template in the editor. */ packpackcom.muxlab.vitex.server.launchercher; import java.lang.reflect.Field; import java.util.*; /** * * @author g.tzabari */ NativeLibraries/* * To change this template, choose Tools | Templates * and open the template in the editor. */ private static final Field loadedLibraryNames; private static final Field systemNativeLibraries; private static final Field nativeLibraries; private static final Field nativeLibraryFromClass; private static final Field nativeLibraryName; static { Field temp; try { temp = ClassLoader.class.getDeclaredField("loadedLibraryNames"); if (temp != null) temp.setAccessible(true); } catch (ReflectiveOperationException e) { e.printStackTrace(); temp = null; } loadedLibraryNames = temp; try { temp = ClassLoader.class.getDeclaredField("systemNativeLibraries"); if (temp != null) temp.setAccessible(true); } catch (ReflectiveOperationException e) { e.printStackTrace(); temp = null; } systemNativeLibraries = temp; try { temp = ClassLoader.class.getDeclaredField("nativeLibraries"); if (temp != null) temp.setAccessible(true); } catch (ReflectiveOperationException e) { e.printStackTrace(); temp = null; } nativeLibraries = temp; Class<?> nativeLibrary = null; for (Class<?> nested : ClassLoader.class.getDeclaredClasses()) { if (nested.getSimpleName().equals("NativeLibrary")) { nativeLibrary = nested; break; } } try { temp = nativeLibrary.getDeclaredField("fromClass"); if (temp != null) temp.setAccessible(true); } catch (ReflectiveOperationException e) { e.printStackTrace(); temp = null; } nativeLibraryFromClass = temp; try { temp = nativeLibrary.getDeclaredField("name"); if (temp != null) temp.setAccessible(true); } catch (ReflectiveOperationException e) { e.printStackTrace(); temp = null; } nativeLibraryName = temp; } public static String[] getLoadedLibraries() { try { @SuppressWarnings(value = "UseOfObsoleteCollectionType") final Vector<String> libraries = (Vector<String>) loadedLibraryNames.get(null); return libraries.toArray(new String[0]); } catch (ReflectiveOperationException e) { e.printStackTrace(); return null; } } /** * Returns the native libraries loaded by the system class loader. * <p/> * @return a Map from the names of native libraries to the classes that loaded them */ /** * Returns the native libraries loaded by the system class loader. * <p/> * @return a Map from the names of native libraries to the classes that loaded them */ public static Map<String, Class<?>> getSystemNativeLibraries() { try { @SuppressWarnings(value = "UseOfObsoleteCollectionType") Map<String, Class<?>> result = new HashMap<>(); final Vector<Object> libraries = (Vector<Object>) systemNativeLibraries.get(null); for (Object nativeLibrary : libraries) { String libraryName = (String) nativeLibraryName.get(nativeLibrary); Class<?> fromClass = (Class<?>) nativeLibraryFromClass.get(nativeLibrary); result.put(libraryName, fromClass); } return result; } catch (ReflectiveOperationException e) { e.printStackTrace(); return null; } } /** * Returns a Map from the names of native libraries to the classes that loaded them. * <p/> * @param loader the ClassLoader that loaded the libraries * @return an empty Map if no native libraries were loaded */ /** * Returns a Map from the names of native libraries to the classes that loaded them. * <p/> * @param loader the ClassLoader that loaded the libraries * @return an empty Map if no native libraries were loaded */ public static Map<String, Class<?>> getNativeLibraries(final ClassLoader loader) { try { @SuppressWarnings(value = "UseOfObsoleteCollectionType") Map<String, Class<?>> result = new HashMap<>(); final Vector<Object> libraries = (Vector<Object>) nativeLibraries.get(loader); for (Object nativeLibrary : libraries) { String libraryName = (String) nativeLibraryName.get(nativeLibrary); Class<?> fromClass = (Class<?>) nativeLibraryFromClass.get(nativeLibrary); result.put(libraryName, fromClass); } return result; } catch (ReflectiveOperationException e) { e.printStackTrace(); return null; } } public static List<ClassLoader> getClassLoaders(ClassLoader loader) { List<ClassLoader> result = new ArrayList<>(); ClassLoader parent = loader.getParent(); result.add(loader); while (parent != null) { result.add(parent); parent = parent.getParent(); } return result; } /** * Returns a Map from the names of native libraries to the classes that loaded them. * <p/> * @param loader the ClassLoader that loaded the libraries * @return an empty Map if no native libraries were loaded */ /** * Returns a Map from the names of native libraries to the classes that loaded them. * <p/> * @param loader the ClassLoader that loaded the libraries * @return an empty Map if no native libraries were loaded */ public static Map<String, Class<?>> getNativeLibrariesRecursive(final ClassLoader loader) { @SuppressWarnings(value = "UseOfObsoleteCollectionType") Map<String, Class<?>> result = new HashMap<>(); ClassLoader parent = loader.getParent(); while (parent != null) { result.putAll(getNativeLibrariesRecursive(parent)); parent = parent.getParent(); } result.putAll(getNativeLibraries(loader)); return result; } age com.muxlab.vitex.server.launcher; /** * * @author g.tzabari */ public class Class { }
generator issue I guess
Anyway is it reproducible? I'm on JDK 6 (JDK 7 is not yet final on Mac) and I cannot reproduce it. This is JDK 7 source.
(In reply to comment #2) > Anyway is it reproducible? > I'm on JDK 6 (JDK 7 is not yet final on Mac) and I cannot reproduce it. > This is JDK 7 source. Works for me on: NetBeans IDE Dev (Build 20111103-75371828b598)(#75371828b598) Linux version 2.6.38-gentoo-r6 running on amd64 1.7.0_147-icedtea; OpenJDK 64-Bit Server VM 21.0-b17; Oracle Corporation OpenJDK Runtime Environment 1.7.0_147-icedtea-b147
I tried several times to reproduce manually, and in the unit tests. Unfortunately, I cannot reproduce this. Sorry, but I need a reproducible testcase, otherwise I do not know where to look. As a start, could you please attach your formatter settings? These two files from the userdir should be enough: config/Editors/Preferences/org-netbeans-modules-editor-settings-CustomPreferences.xml config/Editors/text/x-java/Preferences/org-netbeans-modules-editor-settings-CustomPreferences.xml Thanks.
Created attachment 112842 [details] Testcase It doesn't seem to be formatting related. The userdir paths you mentioned don't exist for me. Specifically, config/Editor is missing. Take a look at the attached testcase. Open up App.java, apply the refactoring to the inner class and you should get a malformed result. PS: I believe this bug is specific to the October 31st build. When I tried an older build from October 5th I couldn't reproduce the problem.
Thanks. The problem appears to be in line endings: internally, the NB infrastructure uses solely '\n' newlines, but the '\r\n'->'\n' conversion is missing on one place, leading to this problem. I am working on a fix.
Fixed: http://hg.netbeans.org/jet-main/rev/07f201c630f8 Gili, Jirka, please verify (mainly on Windows). Thanks.
Integrated into 'main-golden' Changeset: http://hg.netbeans.org/main-golden/rev/07f201c630f8 User: Jan Lahoda <jlahoda@netbeans.org> Log: #204638: need to use '\n' lineendings when diffing newly created files.
The formatting seems to be fine, but there is problem the comments are doubled -> filed as separated issue 206086