Java Doc for BCJava.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » impl » services » bytecode » 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 » Database DBMS » db derby 10.2 » org.apache.derby.impl.services.bytecode 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.derby.impl.services.bytecode.BCJava

BCJava
public class BCJava implements JavaFactory,CacheableFactory,ModuleControl(Code)

Debugging problems with generated classes

When the code has been generated incorrectly, all sorts of odd things can go wrong. This is one recommended approach to finding the problem.

First, turn on ByteCodeGenInstr and DumpClassFile. Look for missing files (right now they are consecutively numbered by the activation class builder; later on they won't be, but BytCodeGenInstr dumps messages about the classes it has). Look at the log to make sure that all "GEN starting class/method" messages are paired with a "GEN ending class/method" message. If a file is missing or the pairing is missing, then something went wrong when the system tried to generate the bytecodes. Resort to your favorite debugging tool to step through the faulty statement.

If you get class files but the system crashes on you (I had an OS segmentation fault once) or you get funny messages like JDBC Excpetion: ac5 where ac5 is just the name of a generated class, then one of the following is likely:

  • you are calling INVOKEVIRTUAL when you are supposed to call INVOKEINTERFACE
  • you have an inexact match on a method argument or return type.
  • you are trying to get to a superclass's field using a subclass.
The best way to locate the problem here is to do this (replace ac5.class with the name of your class file):
  1. javap -c -v ac5 >ac5.gp
    if javap reports "Class not found", and the file ac5.class does exist in the current directory, then the .class file is probably corrupt. Try running mocha on it to see if that works. The problem will be in the code that generates the entries for the class file -- most likely the ConstantPool is bad, an attribute got created incorrectly, or perhaps the instruction streams are goofed up.
  2. java mocha.Decompiler ac5.class
    if mocha cannot create good java source, then you really need to go back and examine the calls creating the java constructs; a parameter might have been null when it should have, a call to turn an expression into a statement may be missing, or something else may be wrong.
  3. mv ac5.mocha ac5.java
  4. vi ac5.java ; you will have to fix any new SQLBoolean(1, ...) calls to be new SQLBoolean(true, ...). Also mocha occasionally messes up other stuff too. Just iterate on it until it builds or you figure out what is wrong with the generated code.
  5. javac ac5.java
  6. javap -v -c ac5 >ac5.jp
  7. sed '1,$s/#[0-9]* ac5.gn
  8. sed '1,$s/#[0-9]* ac5.jn
    These seds are to get rid of constant pool entry numbers, which will be wildly different on the two files.
  9. vdiff32 ac5.gn ac5.jn
    this tool shows you side-by-side diffs. If you change to the window that interleaves the diffs, you can see the length of the line. Look for places where there are invokevirtual vs. invokeinterface differences, differences in the class name of a field, differences in the class name of a method parameter or return type. The generated code will* have some unavoidable differences from the compiled code, such as:
    • it will have goto's at the end of try blocks rather than return's.
    • it will do a getstatic on a static final field rather than inlining the static final field's value
    • it will have more checkcast's in it, since it doesn't see if the checkcast will always succeed and thus remove it.
    Once you find a diff, you need to track down where the call was generated and modify it appropriately: change newMethodCall to newInterfaceMethodCall; add newCastExpression to get a argument into the right type for the parameter; ensure the return type given for the method is its declared return type.

See Also:   org.apache.derby.iapi.services.compiler.JavaFactory
author:
   ames



Constructor Summary
public  BCJava()
    

Method Summary
public  voidboot(boolean create, Properties properties)
     Start this module.
public  CacheablenewCacheable(CacheManager cm)
    
public  ClassBuildernewClassBuilder(ClassFactory cf, String packageName, int modifiers, String className, String superClass)
     a class.
public  voidstop()
     Stop this module.
 Typetype(String javaType)
     Get the VM Type ID that corresponds with the given java type name.
 StringvmType(BCMethodDescriptor md)
    
static  shortvmTypeId(String vmTypeS)
     Map vm types as strings to vm types as the VM handles, with int ids.


Constructor Detail
BCJava
public BCJava()(Code)




Method Detail
boot
public void boot(boolean create, Properties properties) throws StandardException(Code)
Start this module. We need a read/write version of the class utilities
exception:
  StandardException - standard cloudscape policy



newCacheable
public Cacheable newCacheable(CacheManager cm)(Code)



newClassBuilder
public ClassBuilder newClassBuilder(ClassFactory cf, String packageName, int modifiers, String className, String superClass)(Code)
a class. Once it is created, fields, methods, interfaces, static initialization code, and constructors can be added to it. Java: package #packageName; #modifiers #className extends #superClass { } // modifiers is the | of the JVM constants for // the modifiers such as static, public, etc. See java.lang.reflect.Modifiers
Parameters:
  packageName - the name of the package the class is in.null if it is in the default package.
Parameters:
  modifiers - the | of the Modifiersconstants representing the visibility and control of thismethod.
Parameters:
  className - the name of the class or interface
Parameters:
  superClass - the name of the superclass or superinterface the class builder.



stop
public void stop()(Code)
Stop this module. In this case, nothing needs to be done.



type
Type type(String javaType)(Code)
Get the VM Type ID that corresponds with the given java type name. This uses the cache of VM type ids.
Parameters:
  javaType - The java type name to translate to a java VM type id The java VM type ID



vmType
String vmType(BCMethodDescriptor md)(Code)



vmTypeId
static short vmTypeId(String vmTypeS)(Code)
Map vm types as strings to vm types as the VM handles, with int ids. Used in mapping opcodes based on type of operand/stack entry available.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.