473,767 Members | 2,138 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Self Modifying Code

How do you write self modifying code in Java?

Japcuh
(Just Another Perl C Unix Hacker)
http://www.catb.org/~esr/faq/hacker-howto.htm#what_is
..0.
...0
000
Jul 17 '05 #1
16 8143
Japcuh wrote:
How do you write self modifying code in Java?


What do you mean by "modify?" A Java program can
extend itself by loading new classes on the fly, if
that suits your needs.

--
Er*********@sun .com

Jul 17 '05 #2
On 2 Jul 2004 12:31:17 -0700, ja****@gmail.co m (Japcuh) wrote or
quoted :
How do you write self modifying code in Java?


You can't modify a class once it has been loaded, but you can create a
similar class and load that.

You can do it by generating Java source and compiling that on the fly
to byte codes, or by generating JVM byte codes directly.

See http://mindprod.com/jgloss/eval.html
http://mindprod.com/jgloss/jasm.html
http://mindprod.com/jgloss/javacexe.html

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Jul 17 '05 #3
ja****@gmail.co m (Japcuh) wrote in news:3a8cbb2e.0 407021131.55805 361
@posting.google .com:
How do you write self modifying code in Java?


You may want to check out the Java code generation library cglib:
http://cglib.sourceforge.net/

Best Regards
Kristian Larsen
Jul 17 '05 #4
kjc
No, but this could be done in Smalltalk blind folded.

Japcuh wrote:
How do you write self modifying code in Java?

Japcuh
(Just Another Perl C Unix Hacker)
http://www.catb.org/~esr/faq/hacker-howto.htm#what_is
.0.
..0
000


Jul 17 '05 #5
On Sat, 03 Jul 2004 15:49:21 GMT, kjc <ks*****@elp.rr .com> wrote or
quoted :
No, but this could be done in Smalltalk blind folded.

Japcuh wrote:
How do you write self modifying code in Java?


Is it a problem that you sometimes do it accidentally?

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Jul 17 '05 #6
> ja****@gmail.co m (Japcuh) wrote in news:3a8cbb2e.0 407021131.55805 361
@posting.google .com:
How do you write self modifying code in Java?


http://java.sun.com/developer/techni...leases/j2se15/

The metadata bit of this seems to suggest that in future releases of
java, you'll be able to generate actual source code on the fly.
Jul 17 '05 #7
Thanks for all the help.

Japcuh
(Just Another Perl C Unix Hacker)
http://www.catb.org/~esr/faq/hacker-howto.htm#what_is
..0.
...0
000
Jul 17 '05 #8
an************@ gmail.com (Andrew Chambers) wrote in message news:<f3******* *************** **@posting.goog le.com>...
ja****@gmail.co m (Japcuh) wrote in news:3a8cbb2e.0 407021131.55805 361
@posting.google .com:
How do you write self modifying code in Java?


http://java.sun.com/developer/techni...leases/j2se15/

The metadata bit of this seems to suggest that in future releases of
java, you'll be able to generate actual source code on the fly.


I think the metadata is for hints for documentation generation.

I could be wrong.

But I'd hate to work out a security system for Java if they allow the
code to modify itself. Dynamically extending classes is plenty.
Jul 17 '05 #9
kjc <ks*****@elp.rr .com> wrote in message news:<5A******* **********@fe1. texas.rr.com>.. .
No, but this could be done in Smalltalk blind folded.
You can use Java Reflection which is Java's counterpart to Smalltalk's
perform: concatenate some strings to create an existing method name
and call that method. Or you can use the command pattern and add
commands as required to a list and execute them sequentially.

Cheers, Oliver
Japcuh wrote:
How do you write self modifying code in Java?

Japcuh
(Just Another Perl C Unix Hacker)
http://www.catb.org/~esr/faq/hacker-howto.htm#what_is
.0.
..0
000

Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
8321
by: qwweeeit | last post by:
Hi all, when I was young I programmed in an interpreted language that allowed to modify itself. Also Python can (writing and running a module, in-line): fNew =open("newModule.py",'w') lNew= fNew.writelines(lNew) fNew.close()
2
4282
by: Joel Jose | last post by:
agreed the 'mutation engine' by dark avenger was a real deadly master-code piece.., but then.. if one could create a self mutating code..in real time then i think it would just b the most technical advancement of this century!!! just think... instead of those nagging.. and more irritating than helpfull death screen(error logs).. that windows shows every other time.. if it could evolve itself to cope up with the error.. if the pe...
18
2282
by: Ralf W. Grosse-Kunstleve | last post by:
My initial proposal (http://cci.lbl.gov/~rwgk/python/adopt_init_args_2005_07_02.html) didn't exactly get a warm welcome... And Now for Something Completely Different: class autoinit(object): def __init__(self, *args, **keyword_args): self.__dict__.update(
13
2131
by: Robin Becker | last post by:
When young I was warned repeatedly by more knowledgeable folk that self modifying code was dangerous. Is the following idiom dangerous or unpythonic? def func(a): global func, data data = somethingcomplexandcostly() def func(a): return simple(data,a)
12
4822
by: AES | last post by:
Can an HTML web page dynamically modify its own code? (without resort to Java or any other non-HTML complexities) That is, is there any provision in HTML such that a single "Next" button on a main or index.html page will: a) Change an image displayed on that page (say Picture_1.jpg) to the next image in a sequence (say Picture_2.jpg), AND
10
5154
by: jon | last post by:
I am a beginner C programmer, this is actually my first programming lanugage, besides html, cgi, and javascript. I am looking for a way to make an .exe file, or a copy of my own file. I have tried writing a file, compling it, and reading it in a notepad, then writing a program to write it again, but i have had no luck. I assure you i'm not trying to create the next big virus, or worm, but only trying to expaned my knowledge on what...
5
2640
by: IUnknown | last post by:
Ok, we are all aware of the situation where modifying the folder structure (adding files, folders, deleting files, etc) will result in ASP.NET triggering a recompilation/restart of the application. In a nutshell, I understand how this can be considered desireable by some, but I am not one of those people. My situation is that we have a root site (hosted @ http://www.mydomain.com) in the root application folder '/'.
0
9571
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10013
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9960
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9841
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8838
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7383
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6655
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5424
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.