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.
I edit a java file, cutting & pasting really seems to generate this one, and the compile the file (F9) and get an exception saying class or interface expected, the error is usually located at the end of the source file and its the result of part of a method being duplicated after the closing bracket '}' of the class e.g. public class Test{ public class Tesrt(){ } .. .. .. }//end class bracket... public String getErrorLogFileName(){ if(logFile == null){ return ""; } else{ return logFile.getAbsolutePath(); } } } return ""; } else{ return logFile.getAbsolutePath(); } } }
Created attachment 11735 [details] NetBeans log file.
Seems like editor issue. Could you repeat any steps to reproduce it, please?
--------------------------------------------------------------- dateCreated: Fri Oct 24 11:47:03 MDT 2003 type: bug cust_name: Paul Carroll cust_email: Paul.Carroll@ericsson.com jdcid: paulcarroll1 status: Waiting category: java subcategory: classes_io company: Ericsson release: 1.4.2 hardware: x86 OSversion: windows_2000 priority: 4 synopsis: FileOutputStream (with append == false) does not ever write file completely description: FULL PRODUCT VERSION : java version "1.3.1_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01) Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode) and java version "1.4.2" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28) Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode) FULL OS VERSION : Microsoft Windows 2000 [Version 5.00.2195] SP4 EXTRA RELEVANT SYSTEM CONFIGURATION : ClearCase 5.0.0.1 Patches : ClearCase_p2002.05.00-13, ClearCase_p2002.05.00-13, ClearCase_p2002.05.00-18 A DESCRIPTION OF THE PROBLEM : Setup as follows: Clearcase dynamic views mounted to Win2K machine. I have a simple test class that generates a file (view private) on the clearcase view and write some contents into it, then the file is re-written with new contents (which is less that what was originally written to the file) using FileOutputStream (append == false). The contents of the file after it has been re-written is the new contents with the difference of the old contents at the end of the file.First seen this when we had our machine upgrades to Win2K SP4 from Win2K SP3 for security reasons. The IDE I used is NetBeans 3.5.1 which I can reproduce this problem on always but doing the same operation in JBuilder 7 the file is written ok. If I perform the same test but this time write the file to a samba drive the resulting file is ok? STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : First write of file: public class TestFile{ public TestFile(){ int i=0; i=0; i=1; i=2; i=3; i=4; } } Contents to be re-written to file are : public class TestFile{ public TestFile(){ int i=0; i=0; } } EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - public class TestFile{ public TestFile(){ int i=0; i=0; } } ACTUAL - Resulting file is : public class TestFile{ public TestFile(){ int i=0; i=0; } }1; i=2; i=3; i=4; } } REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.io.*; public class FileWriteTest { public static String generate(int loop){ String old_c = "public class TestFile{\n\tpublic TestFile(){"; old_c += "\n\t\tint i=0;"; for(int i=0;i<loop;i++){ old_c += "\n\t\ti="+i+";"; } old_c += "\n\t}\n}"; return old_c; } public static void doit(String filename){ File f = new File(filename); if(!f.exists()){ try{ boolean b = f.createNewFile(); System.out.println("File did not exist, created == "+b); } catch(IOException e){ e.printStackTrace(); } } OutputStream os = null; try{ os = new FileOutputStream (filename,false); String c = generate(5); os.write(c.getBytes()); System.out.println("File contents written."); os.close(); os=null; os = new FileOutputStream (filename,false); c = generate(1); os.write(c.getBytes()); os.flush(); os.close(); System.out.println("File contents over-written."); } catch(Throwable t){ t.printStackTrace(); } finally{ if(os!=null){ try{ os.close(); } catch(Throwable t){ t.printStackTrace(); } } } } public static void main(String[] args) { String filename = "some file on clearcase dynamic view "; doit(filename); filename = "C:/Documents and Settings/user/Desktop/ide/TestFile.java"; doit(filename); } } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : None for NetBeans. workaround:
I did a little more poking around and found it to be a Java/Win2K(SP4)/ClearCase interaction problem. Basically the FileOutputStream (with 'append' set to false in the constructor) does not empty out the file prior to writing to it resulting in the difference being lest in the file if the new contents being written to it are less that the original contents..... I have a bug submitted on Java's site (still internal to the above comments are what I submitted(a little trigger happy on the commits) The BugId is 217556 /Paul.
The problem is connected with the the issue #33040 (look at the exceptions in ide.log) that was duplicated to #33165. *** This issue has been marked as a duplicate of 33165 ***