Source Code Cross Referenced for ClassFinalizer.java in  » Development » proguard » proguard » optimize » peephole » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Development » proguard » proguard.optimize.peephole 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ProGuard -- shrinking, optimization, obfuscation, and preverification
003:         *             of Java bytecode.
004:         *
005:         * Copyright (c) 2002-2003 Eric Lafortune (eric@graphics.cornell.edu)
006:         *
007:         * This program is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU General Public License as published by the Free
009:         * Software Foundation; either version 2 of the License, or (at your option)
010:         * any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful, but WITHOUT
013:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
014:         * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
015:         * more details.
016:         *
017:         * You should have received a copy of the GNU General Public License along
018:         * with this program; if not, write to the Free Software Foundation, Inc.,
019:         * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020:         */
021:        package proguard.optimize.peephole;
022:
023:        import proguard.classfile.*;
024:        import proguard.classfile.util.*;
025:        import proguard.classfile.visitor.*;
026:        import proguard.optimize.KeepMarker;
027:
028:        /**
029:         * This <code>ClassVisitor</code> and <code>MemberVisitor</code>
030:         * makes the classes it visits, and their methods, final, if possible.
031:         *
032:         * @author Eric Lafortune
033:         */
034:        public class ClassFinalizer extends SimplifiedVisitor implements 
035:                ClassVisitor, MemberVisitor {
036:            private final ClassVisitor extraClassVisitor;
037:            private final MemberVisitor extraMemberVisitor;
038:
039:            private final MemberFinder memberFinder = new MemberFinder();
040:
041:            /**
042:             * Creates a new ClassFinalizer.
043:             */
044:            public ClassFinalizer() {
045:                this (null, null);
046:            }
047:
048:            /**
049:             * Creates a new ClassFinalizer.
050:             * @param extraClassVisitor  an optional extra visitor for all finalized
051:             *                           classes.
052:             * @param extraMemberVisitor an optional extra visitor for all finalized
053:             *                           methods.
054:             */
055:            public ClassFinalizer(ClassVisitor extraClassVisitor,
056:                    MemberVisitor extraMemberVisitor) {
057:                this .extraClassVisitor = extraClassVisitor;
058:                this .extraMemberVisitor = extraMemberVisitor;
059:            }
060:
061:            // Implementations for ClassVisitor.
062:
063:            public void visitProgramClass(ProgramClass programClass) {
064:                // If the class is not final/interface/abstract,
065:                // and it is not being kept,
066:                // and it doesn't have any subclasses,
067:                // then make it final.
068:                if ((programClass.u2accessFlags & (ClassConstants.INTERNAL_ACC_FINAL
069:                        | ClassConstants.INTERNAL_ACC_INTERFACE | ClassConstants.INTERNAL_ACC_ABSTRACT)) == 0
070:                        && !KeepMarker.isKept(programClass)
071:                        && programClass.subClasses == null) {
072:                    programClass.u2accessFlags |= ClassConstants.INTERNAL_ACC_FINAL;
073:
074:                    // Visit the class, if required.
075:                    if (extraClassVisitor != null) {
076:                        extraClassVisitor.visitProgramClass(programClass);
077:                    }
078:                }
079:
080:                // Check all methods.
081:                programClass.methodsAccept(this );
082:            }
083:
084:            // Implementations for MemberVisitor.
085:
086:            public void visitProgramMethod(ProgramClass programClass,
087:                    ProgramMethod programMethod) {
088:                String name = programMethod.getName(programClass);
089:
090:                // If the method is not already private/static/final/abstract,
091:                // and it is not a constructor,
092:                // and its class is final,
093:                //     or it is not being kept and it is not overridden,
094:                // then make it final.
095:                if ((programMethod.u2accessFlags & (ClassConstants.INTERNAL_ACC_PRIVATE
096:                        | ClassConstants.INTERNAL_ACC_STATIC
097:                        | ClassConstants.INTERNAL_ACC_FINAL | ClassConstants.INTERNAL_ACC_ABSTRACT)) == 0
098:                        && !name
099:                                .equals(ClassConstants.INTERNAL_METHOD_NAME_INIT)
100:                        && ((programClass.u2accessFlags & ClassConstants.INTERNAL_ACC_FINAL) != 0 || (!KeepMarker
101:                                .isKept(programMethod) && (programClass.subClasses == null || !memberFinder
102:                                .isOverriden(programClass, programMethod))))) {
103:                    programMethod.u2accessFlags |= ClassConstants.INTERNAL_ACC_FINAL;
104:
105:                    // Visit the method, if required.
106:                    if (extraMemberVisitor != null) {
107:                        extraMemberVisitor.visitProgramMethod(programClass,
108:                                programMethod);
109:                    }
110:                }
111:            }
112:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.