Manually Adding Exception Table Entry

Apr 7, 2014

I use Javassist to manually add a exception table entry:

Java Code:

MethodInfo minfo = (MethodInfo) aclasscf.getMethods().get(0);
CodeAttribute ca = minfo.getCodeAttribute();
ExceptionTable et = ca.getExceptionTable();
et.add(26, 30, 40, 0);
System.out.println("exception table size: " + et.size()); mh_sh_highlight_all('java');

If I get the bytecode with javap it seems to work:

Java Code:

Exception Table
from to target type
26 30 40 any mh_sh_highlight_all('java');

But the problem is that I can't run the file anymore. Simply running it with the java command results in "java.lang.VerifyError: Expecting a stackmap frame at branch target 40". After some research this seems to be a problem with java 7 and a stricter verifier. I read several times that java -XX:-UseSplitVerifier should be used instead.

This really fixed the stackmap error, but then another error appeared: "java.lang.VerifyError: (class: AClass, method: signature: ()V) Inconsistent stack height 2 != 1". Are there any further steps required to insert a new exception in the exception table?

Additional info: Later I want to remove gotos (in this case the goto at line 27) and add a function call instead. When this function finishes it will throw a exception and propagate it back to the caller (which will be at line 27). Then the program should go on as if nothing happend, that is also the reason why the target of the exception is the same as the target of the goto (40)

Here is the bytecode:

Java Code:

0: aload_0
1: invokespecial #8 // Method java/lang/Object."<init>":()V
4: iconst_0
5: istore_1
6: goto 19
9: getstatic #10 // Field java/lang/System.out:Ljava/io/PrintStream;
12: iload_1
13: invokevirtual #16 // Method java/io/PrintStream.println:(I)V

[Code] .....

Exception table:
from to target type
26 30 40 any mh_sh_highlight_all('java');

View Replies


ADVERTISEMENT

Manually Add Exception Table Entry?

Apr 8, 2014

because of the need to implement a certain software watermarking technique I have to manipulate the exception table.
 
(Link to the paper that describes the technique: [URL] .... (Section "Extension to Java Bytecode")
   
So far I could manually add the exception table entry with Javassist:
 
MethodInfo minfo = (MethodInfo) aclasscf.getMethods().get(0);
CodeAttribute ca = minfo.getCodeAttribute();
ExceptionTable et = ca.getExceptionTable();

[Code]....

View Replies View Related

Adding Entry To PATH Variable In Bin Directory

Dec 24, 2013

I'm using Ubuntu. After unpacking the tar file for JSE 1.7 version 45, in the the bin directory for adding an entry to PATH variable, I typed

javac

and I get the message

The program 'javac' can be found in the following packages:
* default-jdk
* ecj
* gcj-4.6-jdk
* gcj-4.7-jdk
* openjdk-7-jdk
* openjdk-6-jdk
Try: sudo apt-get install <selected package>

Do I have to install these ?

View Replies View Related

Adding Data In Table But The Table Is In Another Frame

Mar 13, 2014

This is my codes in a button that if I click it . that information will send to Jtable but the problem is the jtable is in another frame so how can i connect this ?

DefaultTableModel model = (DefaultTableModel)
new admin().tableBagtags.getModel();
if (txtName.getText().equals("")) {
JOptionPane.showMessageDialog(null, "Please fill out all fields.", "Error!", JOptionPane.ERROR_MESSAGE);

[Code] .....

View Replies View Related

Adding Numbers In Table?

Mar 11, 2014

how can I add the numbers in quantity where it will automatically put in total?

im using netbeans.

just want the codes for how to add the listed quantity?

View Replies View Related

Adding Inputs To Table With Columns And Perform Calculations Later

Nov 22, 2014

I am trying to put together a small application in my spare time. Nothing major, but one thing I want it to do is accept a few inputs, and take those and add them to a table with columns for use later (printing, calculations, etc). I was originally looking at something like Jtable, but that looks just like an excel spreadsheet done Java, so not what I'm looking for.

I'm looking for something that's read-only, where I can insert data from input fields, and then perform calculations with the column data later.

View Replies View Related

JSP / JSTL :: Adding Column With Checkboxes For Each Record In Table?

Mar 18, 2013

How I can add a column with check boxes for each record in my table in JSP? Also, I want to figure out a way that what records the user has checked!

View Replies View Related

Swing/AWT/SWT :: Null Pointer Exception When Retrieving Data From Table

Mar 31, 2015

I am trying to export data from a jtable to a pdf report but every time i try running the code it gives me this exception:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at GUI.QC_receiving_book.printButtonActionPerformed(QC_receiving_book.java:309)
at GUI.QC_receiving_book.access$600(QC_receiving_book.java:26)
at GUI.QC_receiving_book$7.actionPerformed(QC_receiving_book.java:165)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)

[Code] ....

I tried avoiding the null exception by using the if statement but it didn't work. The row I choose from the table is full meaning there are no empty attributes. and all the data are imported from a mysql database to the table as String so there can't be any casting errors.

This is the part of the source code with the problem and i will also post the printing method. I tried debugging the class and when stepping into the first if statement it opened the jTable.java file and pointed at the getSelectedRow() method and this sentence "variable information not available.source compiled without -g option"

private void printButtonActionPerformed(java.awt.event.ActionEvent evt) {
if(samplesTable.getSelectedRow() >= 0){
int row = samplesTable.getSelectedRow();
System.out.println(row);
for(int x=0;x<samplesTable.getColumnCount();x++){
String value = samplesTable.getModel().getValueAt(row, x).toString();

[Code] ....

View Replies View Related

Adding And Subtracting In Budget Program - Display Table Showing Transactions

Mar 15, 2014

Budget program. Here is my situation, I have 2 tabs in a GUI, one tab adds a transactions when the add button is clicked, and in the other tab displays a table showing all the transactions. In my code, I want it so that when the user chooses a deposit(combo box variable name = cbType, indexnumber for deposit is 0) it will add to the total and when the user chooses withdraw(index number is 1) then it will subtract it from the total. Here is the code.... (note as well, the code also adds a new row to the table)

//add button clicked
private class BtnAddActionListener implements ActionListener {
public void actionPerformed(ActionEvent arg0) {
((DefaultTableModel)table.getModel()).addRow(new Object[]{
cbMonth.getSelectedItem() + "/" + txtDay.getText() + "/" + cbYear.getSelectedItem(),
cbCategory.getSelectedItem(),

[Code] .....

So when I tested the program with 2 transactions, the first transaction was a deposit and the 2nd transaction was a withdraw. The end product was that both amounts were subtracted from the total. When I did a withdraw first and a deposit second, the amounts were both added together.

View Replies View Related

Java 8u40 Application Blocked Even After Adding To Exception List

Mar 30, 2015

Have a user who cannot access a file on website for work he needs to do. He gets these errors:

His Java is the latest and I have already added the site to the exceptions list in, Java and the browser, but I can't get through.

View Replies View Related

Check To See If Entry Is Either Primitive Or String?

Feb 5, 2015

Is it possible to check to see if a what a user has entered is a string or a other variable type, if I'm asking this the right way?

View Replies View Related

How To Manually Put Data Into InputStream

Aug 23, 2014

I am new to programming in regards to I/O, channels, SSH, etc...

At the moment I am trying to transform the Shell.java program from the JCraft JSch examples; JSch - Java Secure Channel - Examples

The way in which I am trying to transform it is by instead of having the character input go into the channel automatically from the keyboard (refer to line 77 in Shell.java), I just want to pro-grammatically insert characters in to the channel at my discretion, so for example I have a string called unixCommand that I want to insert into the channel, and I don't want there to be any other way of inserting into the channel such as the standard input stream, so for example I'd have the statement <insert unixCommand to UNIX box at other side of channel> inserted somewhere after line 100 in Shell.java.

I was thinking that maybe I have to use some other InputStream object at line 77 when setting the channels input stream instead of System.in, but I am not sure how to do this (but really I'm not sure if I'm even on the right tracks?). I believe all this confusion may be down to a misunderstanding with the general concepts involved with channels and I/O ...

View Replies View Related

Manually Include Java API?

May 7, 2014

For some reason, when I generate a Javadoc (using javadoc.exe of JDK 8), it displays Java-defined classes like java.lang.String and java.lang.Object by their full names rather than simply String or Object. Only the classes inside the packaged contents were represented by their simple names and linked to them (had visible coloured bolding). Was I supposed to manually include the Java API?

View Replies View Related

How To Manually Put Data Into InputStream

Aug 23, 2014

I am trying to transform the Shell.java program from the JCraft JSch examples : [URL] ....

The way in which I am trying to transform it is by instead of having the character input go into the channel automatically from the keyboard (refer to line 77 in Shell.java), I just want to pro-grammatically insert characters in to the channel at my discretion, so for example I have a string called unixCommand that I want to insert into the channel, and I don't want there to be any other way of inserting into the channel such as the standard input stream, so for example I'd have the statement <insert unixCommand to UNIX box at other side of channel> inserted somewhere after line 100 in Shell.java.

I was thinking that maybe I have to use some other InputStream object at line 77 when setting the channels input stream instead of System.in, but I am not sure how to do this (but really I'm not sure if I'm even on the right tracks?). I believe all this confusion may be down to a misunderstanding with the general concepts involved with channels and I/O.

View Replies View Related

Swing/AWT/SWT :: Restricting Data Entry In TextFields

Mar 4, 2015

I'd like to know is there a way to restrict a user from inputting certain characters into a TextField? Is there something like isNumeric() available?

In Visual Basic, I was able to prevent the user entering certain characters of my choice into each textbox, however I've looked and I haven't been able to find a solution. I've tried using the following else if as part of an if statement:

else if (txtEmployeeName.getText().contains("[0-9]+"){ }

but it doesn't seem to work.

View Replies View Related

Servlets :: Null Retrieved From Env-entry Resource

Jan 9, 2009

I have an env-entry defined in my web.xml and when I attempt to print it from a simple servlet all I get is null. And of course if I attempt to invoke any methods on the object I get a NullPointerException.I read somewhere that this can happen if you're using version 2.4 instead of 2.5, so I changed to 2.5 and I still have the same issue. Here's the web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd">
<display-name>ResourceTest</display-name>
<servlet>

[code]....

View Replies View Related

Repeating A Program Until Manually Terminated?

Jun 22, 2014

My homework assignment is to create a program that reads two military times and then prints out the elapsed time. I've got all that down and ready to go but then the other part of this project is to have it loop until it is terminated manually. So at the end where it asks for a 'Y' or 'N' input answer is where I know i need to implement a do-while loop or switch statement, I'm not sure. how to make the application repeat until told to quit.

View Replies View Related

JSF :: Finding Index Of Entry In ArrayList - Select Item

Oct 2, 2014

I have a JSF application with this code in the xhtml page:

<h:selectOneListbox id="selectProduct" size="10" style="width:10em; font-family:monospace" value="#{mybean.product}">
<f:selectItems value="#{mybean.products}" />
</h:selectOneListbox>

and the corresponding snippets of the Java code are:

// Class member variables
// ...
private String product;
private ArrayList<String> productValues;
private ArrayList<String> productLabels;
private SelectItem[] products;
// ... Various properties etc.
public String getLocation() { // Displayed on a page

[code]....

Most of this works correctly using only ArrayList SelectItem products without the two ArrayList and the separate SelectItem[], and the values and labels are put directly into products here. The menu works and I can select an item. However, I am unable to find the correct method for finding the index in the submit method,namely:

public void submit(ActionEvent e) {
showProduct = true;
prodNum = products.indexOf(product); // --- Here is the problem!
updateProduct();
}

which has not been changed here. In spite of trying out various ideas, prodNum always returns with -1, which means it cannot find the index of the selected product, where product is a String. Everything else seems to work correctly, and products.get(prodNum).getLabel() works if I manually give prodNum a valid index, but because it's -1 it fails.

View Replies View Related

Swing/AWT/SWT :: Manually Select A Node In JTree?

Oct 24, 2014

I have problem with manually (through my java code) selecting items in a JTree. I did Google the problem and found solutions here :

[URL]

This code worked for me only partially. Once I tried selecting deeper nested nodes, I ran into problems. Since my production code is very cluttered I built an example and reproduced my exact problem in it.

DummyView.java
package de.fortis.tcws.client.controller;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

[code].....

The important method is 'manualSelect(String[])'.

It streps through the tree by comparing user objects and finds the target node. Then it calls 'navigateToNode()' which uses the solution discussed in the links above.

This method behaves incosistently:

If you call it with an empty array it will correctly select the root node. The righthand pane shows the text of the selected node. = correct

If you call it with target node 1 it will correctly select node 1. The righthand pane shows the text of the selected node. = correct

If you call it with target node 1.1 it will select node 1.1 but for some reason it is not displayed as marked (no background). The righthand pane shows the text of the selected node. = only partly correct

If you call it with target node A it will run into an exception. Debugging reveals that the selection occurs correclty at first. You can also observe the righthand pane showing that 'A' was selected. But afterwards another TreeselectionEvent is occuring that has a NewLeadSelectionPath of null. I do not know where this second SelectionEvent is triggered from.

This code is run with Java 1.6.0_39 which is also what I will have to use in production.

View Replies View Related

How To Call Action Listener Automatically And Without Doing It Manually

May 16, 2014

I'm not a java developer, i'm a tester. I am currently testing a java swing application and to do that I have to automate how its used. IE I have to write code which will press buttons for me rather than depending on an end user to do this. I have managed to reverse engineer the entire application (hooray for me), however I am struggling to work out how to invoke methods that would typically be kicked off by a user pressing a button. how to I can call actionPerformed(ActionEvent ae) method which sits in the ATMMainPanel class?

I will be calling it from inside another method which is the equivalent of the main() method.

Java Code:

public class ATMMainPanel extends JPanel implements ActionListener {
[declarations here]
//here - User is pressing the Enter button after putting in pin.
public void actionPerformed(ActionEvent ae) {
[code performed when button is pressed]
} mh_sh_highlight_all('java');

View Replies View Related

Launch Windows Directly Into JAVA Based Password Entry System?

Apr 5, 2014

Is it possible to launch windows, specifically 8.1, directly into a java based program which would serve as the password entry screen? That is to say, instead of using the standard windows screen, could a java based alternative be used?

I have the source code used on jurassicsystems.com. I would absolutely kill to have a tweaked version of this system act as my password entry screen. It is literally something Ive wanted to have done for ages, and this emulation finally means it may be possible.

View Replies View Related

JavaFX 2.0 :: How To Define Cell In The Table By Table Event

Mar 23, 2015

How to define Cell in the table by table event?
 
I need to process one component drag to the table. I misunderstand, how I can see to which Cell fall the component. I tried to use Event and Mouse event handlers in my custom Cell, but they do not work. I can copy the drag event to the table and table handles it, but how to get needed Cell I cant understand.

View Replies View Related

JSF :: Unable To Add Mysql Table Columns To Table

Apr 29, 2014

I'm trying to add some mysql table columns to JSF table. And I'm getting error:

/index.xhtml: The class 'logon.User' does not have the property 'description'.

User.java
package logon;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

[Code]...

View Replies View Related

How To Append New Entry In A List Of 100,000 Names Without Iterating List Each Time

Apr 22, 2015

I have a list of 100,000 + names and I need to append to that list another 100,000 names. Each name must be unique. Currently I iterate through the entire list to be sure the name does not exist. As you can imagine this is very slow. I am new to Java and I am maintaining a 15+ year old product. Is there a better way to check for an existing name?

View Replies View Related

What Handling Exception And Declaring Same Exception In Throws Clause Achieve

Jan 24, 2014

I was giving a quick skim to some tutorials on the internet where I have found the exception that is handled is also declared in the throws clause of the method wrapping the try-catch block. For a code representation consider the following:

public void methodName() throws IOException {
try {
...
} catch (IOException ex) {
.... TODO handle exception
}

}

View Replies View Related

Manually Sorting Array Into Another Array

Jan 28, 2015

This piece of code i cannot change

public class Lab
{
public static void main(string args[]) {
int ar[]={7,5,2,8,4,9,6};
int sorted[]=new int[ar.length];

/// my code is right here this i can change i keep getting array required int found i'm not sure what i'm doing wrong i do know i need 2 for loops and an if statement.

[code]for(i=0;i<ar.length;i++){
for(j=i+1;j<ar.length;j++){
if(ar.length[i]>ar.length[j]
this piece of code cannot change
for(int i = 0; i<sorted.length; i++)
{
system.out.println("sorted[" + i + "] = " + sorted[i]);[/code]

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved